{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "now =datetime.now()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2019, 3, 14, 14, 4, 1, 860491)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2019, 3, 14)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now.year,now.month,now.day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "delta = datetime(2011,1,7) - datetime(2008,6,24,8,15)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.timedelta(926, 56700)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "926"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "56700"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta.seconds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2010, 12, 14, 0, 0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from datetime import timedelta\n",
    "start = datetime(2011, 1, 7)\n",
    "start + timedelta(12)\n",
    "start - 2 * timedelta(12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2011-01-03'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " stamp = datetime(2011, 1, 3)\n",
    "str(stamp)\n",
    "stamp.strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from dateutil.parser import parse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2019, 1, 1, 0, 0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "parse('20190101')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "datestrs = ['2011-07-06 12:00:00', '2011-08-06 00:00:00']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2011-07-06 12:00:00', '2011-08-06 00:00:00'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.to_datetime(datestrs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "idx = pd.to_datetime(datestrs+[None])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2011-07-06 12:00:00', '2011-08-06 00:00:00', 'NaT'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([False, False,  True])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.isnull(idx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [40]: dates = [datetime(2011, 1, 2), datetime(2011, 1, 5),\n",
    "....: datetime(2011, 1, 7), datetime(2011, 1, 8),\n",
    "....: datetime(2011, 1, 10), datetime(2011, 1, 12)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[datetime.datetime(2011, 1, 2, 0, 0),\n",
       " datetime.datetime(2011, 1, 5, 0, 0),\n",
       " datetime.datetime(2011, 1, 7, 0, 0),\n",
       " datetime.datetime(2011, 1, 8, 0, 0),\n",
       " datetime.datetime(2011, 1, 10, 0, 0),\n",
       " datetime.datetime(2011, 1, 12, 0, 0)]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts = pd.Series(np.random.randn(6),index=dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    0.681288\n",
       "2011-01-05   -0.165217\n",
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "2011-01-12    1.050169\n",
       "dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2011-01-02', '2011-01-05', '2011-01-07', '2011-01-08',\n",
       "               '2011-01-10', '2011-01-12'],\n",
       "              dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    1.362577\n",
       "2011-01-05         NaN\n",
       "2011-01-07   -1.915111\n",
       "2011-01-08         NaN\n",
       "2011-01-10   -0.914236\n",
       "2011-01-12         NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts + ts[::2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('<M8[ns]')"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.index.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2011, 1, 3, 0, 0)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "stamp = ts.index[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2011-01-02 00:00:00')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "stamp = ts.index[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.9575555332200606"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts[stamp]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.45711824833705145"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts['1/10/2011']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.45711824833705145"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts['20110110']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "longer_ts = pd.Series(np.random.randn(1000),index=pd.date_range('1/1/2000',periods=1000))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01    0.370465\n",
       "2000-01-02   -0.211894\n",
       "2000-01-03    1.116579\n",
       "2000-01-04   -0.805416\n",
       "2000-01-05   -0.366180\n",
       "2000-01-06   -1.289693\n",
       "2000-01-07   -0.304911\n",
       "2000-01-08   -1.040820\n",
       "2000-01-09    0.480737\n",
       "2000-01-10    0.256831\n",
       "2000-01-11    0.178662\n",
       "2000-01-12   -0.524270\n",
       "2000-01-13    1.531840\n",
       "2000-01-14    0.423584\n",
       "2000-01-15   -0.669938\n",
       "2000-01-16    0.320278\n",
       "2000-01-17    1.302130\n",
       "2000-01-18    0.507153\n",
       "2000-01-19   -0.175682\n",
       "2000-01-20    0.584863\n",
       "2000-01-21   -0.453007\n",
       "2000-01-22   -0.747393\n",
       "2000-01-23   -0.052483\n",
       "2000-01-24   -0.767908\n",
       "2000-01-25    1.659045\n",
       "2000-01-26    1.833269\n",
       "2000-01-27   -1.644784\n",
       "2000-01-28   -0.043488\n",
       "2000-01-29    1.363986\n",
       "2000-01-30    0.188136\n",
       "                ...   \n",
       "2002-08-28    1.658070\n",
       "2002-08-29    0.638636\n",
       "2002-08-30    1.624465\n",
       "2002-08-31    1.209776\n",
       "2002-09-01   -0.135161\n",
       "2002-09-02   -0.597779\n",
       "2002-09-03    0.019553\n",
       "2002-09-04   -0.332608\n",
       "2002-09-05    0.040004\n",
       "2002-09-06    0.155105\n",
       "2002-09-07    1.015412\n",
       "2002-09-08   -1.925532\n",
       "2002-09-09    0.793429\n",
       "2002-09-10    0.058768\n",
       "2002-09-11    1.700392\n",
       "2002-09-12    0.217572\n",
       "2002-09-13    1.208645\n",
       "2002-09-14   -2.242904\n",
       "2002-09-15   -1.123203\n",
       "2002-09-16   -0.216792\n",
       "2002-09-17    0.286307\n",
       "2002-09-18    0.143900\n",
       "2002-09-19    0.456226\n",
       "2002-09-20    0.417271\n",
       "2002-09-21    1.642259\n",
       "2002-09-22    0.481497\n",
       "2002-09-23   -0.414551\n",
       "2002-09-24   -1.062455\n",
       "2002-09-25   -0.499623\n",
       "2002-09-26   -0.483035\n",
       "Freq: D, Length: 1000, dtype: float64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "longer_ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2001-01-01   -1.616244\n",
       "2001-01-02    0.412709\n",
       "2001-01-03   -0.634971\n",
       "2001-01-04   -0.484282\n",
       "2001-01-05   -1.072847\n",
       "2001-01-06    0.125091\n",
       "2001-01-07    0.712807\n",
       "2001-01-08   -0.641078\n",
       "2001-01-09    0.391379\n",
       "2001-01-10   -0.758304\n",
       "2001-01-11    0.738941\n",
       "2001-01-12   -1.096013\n",
       "2001-01-13    0.557379\n",
       "2001-01-14    2.430484\n",
       "2001-01-15    0.273479\n",
       "2001-01-16   -0.254533\n",
       "2001-01-17    1.079506\n",
       "2001-01-18   -0.032930\n",
       "2001-01-19    0.463009\n",
       "2001-01-20    0.521538\n",
       "2001-01-21   -0.141941\n",
       "2001-01-22   -0.234875\n",
       "2001-01-23   -0.078679\n",
       "2001-01-24    0.638170\n",
       "2001-01-25   -0.148860\n",
       "2001-01-26    0.933765\n",
       "2001-01-27    0.575641\n",
       "2001-01-28   -0.220390\n",
       "2001-01-29    1.531844\n",
       "2001-01-30   -0.542322\n",
       "                ...   \n",
       "2001-12-02    0.634785\n",
       "2001-12-03   -0.339801\n",
       "2001-12-04    0.354758\n",
       "2001-12-05    0.397232\n",
       "2001-12-06   -0.264906\n",
       "2001-12-07    1.652259\n",
       "2001-12-08   -0.570997\n",
       "2001-12-09    1.557349\n",
       "2001-12-10    0.789005\n",
       "2001-12-11   -0.606476\n",
       "2001-12-12   -0.346326\n",
       "2001-12-13   -1.409638\n",
       "2001-12-14    1.220955\n",
       "2001-12-15    0.793714\n",
       "2001-12-16   -1.133982\n",
       "2001-12-17    2.264773\n",
       "2001-12-18    0.255815\n",
       "2001-12-19   -0.427557\n",
       "2001-12-20   -0.178940\n",
       "2001-12-21    0.810051\n",
       "2001-12-22   -2.214535\n",
       "2001-12-23   -0.963701\n",
       "2001-12-24   -0.379618\n",
       "2001-12-25   -0.459716\n",
       "2001-12-26    0.102533\n",
       "2001-12-27    2.056274\n",
       "2001-12-28    1.153355\n",
       "2001-12-29    1.208807\n",
       "2001-12-30   -1.908606\n",
       "2001-12-31   -1.072719\n",
       "Freq: D, Length: 365, dtype: float64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "longer_ts['2001']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2001-05-01   -0.628948\n",
       "2001-05-02   -2.195368\n",
       "2001-05-03   -0.283049\n",
       "2001-05-04   -0.685106\n",
       "2001-05-05   -0.217960\n",
       "2001-05-06   -0.590141\n",
       "2001-05-07   -0.765482\n",
       "2001-05-08    1.364989\n",
       "2001-05-09   -0.531024\n",
       "2001-05-10    0.656245\n",
       "2001-05-11   -0.511397\n",
       "2001-05-12    1.334960\n",
       "2001-05-13   -0.326905\n",
       "2001-05-14   -0.179222\n",
       "2001-05-15    1.683841\n",
       "2001-05-16   -1.364764\n",
       "2001-05-17    0.188113\n",
       "2001-05-18    1.647162\n",
       "2001-05-19   -0.872891\n",
       "2001-05-20   -0.244634\n",
       "2001-05-21    0.226765\n",
       "2001-05-22   -0.819539\n",
       "2001-05-23   -1.876456\n",
       "2001-05-24    1.087800\n",
       "2001-05-25   -0.472338\n",
       "2001-05-26    1.300364\n",
       "2001-05-27    0.362692\n",
       "2001-05-28   -0.692772\n",
       "2001-05-29    0.471491\n",
       "2001-05-30   -0.059823\n",
       "2001-05-31    0.127446\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "longer_ts['2001-05']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    0.681288\n",
       "2011-01-05   -0.165217\n",
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "2011-01-12    1.050169\n",
       "dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "2011-01-12    1.050169\n",
       "dtype: float64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts[datetime(2011,1,7):]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    0.681288\n",
       "2011-01-05   -0.165217\n",
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "2011-01-12    1.050169\n",
       "dtype: float64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "dtype: float64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts['2011-1-6':'2011-1-11']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    0.681288\n",
       "2011-01-05   -0.165217\n",
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "dtype: float64"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.truncate(after='2011-1-9')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "dates = pd.date_range('2000-1-1',periods=100,freq='W-WED')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [61]: long_df = pd.DataFrame(np.random.randn(100, 4),\n",
    "....: index=dates,\n",
    "....: columns=['Colorado', 'Texas',\n",
    "....: 'New York', 'Ohio'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>New York</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td>0.178709</td>\n",
       "      <td>-0.436959</td>\n",
       "      <td>0.027527</td>\n",
       "      <td>-0.111819</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-12</th>\n",
       "      <td>-0.462057</td>\n",
       "      <td>0.312247</td>\n",
       "      <td>-0.750338</td>\n",
       "      <td>-1.281810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-19</th>\n",
       "      <td>-0.604611</td>\n",
       "      <td>-0.542479</td>\n",
       "      <td>-0.129404</td>\n",
       "      <td>0.039914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-26</th>\n",
       "      <td>1.008442</td>\n",
       "      <td>-0.400774</td>\n",
       "      <td>-0.553412</td>\n",
       "      <td>-2.735263</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-02</th>\n",
       "      <td>-1.069274</td>\n",
       "      <td>-1.173618</td>\n",
       "      <td>-0.098873</td>\n",
       "      <td>-0.885242</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-09</th>\n",
       "      <td>0.391516</td>\n",
       "      <td>0.792966</td>\n",
       "      <td>-0.938487</td>\n",
       "      <td>-0.656885</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-16</th>\n",
       "      <td>-0.809133</td>\n",
       "      <td>1.415891</td>\n",
       "      <td>-0.572519</td>\n",
       "      <td>-0.783915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-23</th>\n",
       "      <td>0.114427</td>\n",
       "      <td>1.798014</td>\n",
       "      <td>-0.412250</td>\n",
       "      <td>0.087347</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-01</th>\n",
       "      <td>-0.070397</td>\n",
       "      <td>0.212633</td>\n",
       "      <td>-2.783785</td>\n",
       "      <td>-2.201481</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-08</th>\n",
       "      <td>-0.935894</td>\n",
       "      <td>0.631474</td>\n",
       "      <td>0.754077</td>\n",
       "      <td>0.424486</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-15</th>\n",
       "      <td>-0.105064</td>\n",
       "      <td>0.641382</td>\n",
       "      <td>-0.868503</td>\n",
       "      <td>0.779417</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-22</th>\n",
       "      <td>-0.634459</td>\n",
       "      <td>-1.756969</td>\n",
       "      <td>-0.687005</td>\n",
       "      <td>0.437763</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-29</th>\n",
       "      <td>1.190979</td>\n",
       "      <td>0.444920</td>\n",
       "      <td>0.309566</td>\n",
       "      <td>0.438933</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-05</th>\n",
       "      <td>-1.038103</td>\n",
       "      <td>-0.752969</td>\n",
       "      <td>0.333955</td>\n",
       "      <td>0.244031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-12</th>\n",
       "      <td>0.179222</td>\n",
       "      <td>0.055535</td>\n",
       "      <td>0.044080</td>\n",
       "      <td>0.662187</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-19</th>\n",
       "      <td>-0.027065</td>\n",
       "      <td>0.307245</td>\n",
       "      <td>-0.687913</td>\n",
       "      <td>-0.816030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-26</th>\n",
       "      <td>-1.010621</td>\n",
       "      <td>-0.439418</td>\n",
       "      <td>-0.527900</td>\n",
       "      <td>-0.124568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-03</th>\n",
       "      <td>-0.005107</td>\n",
       "      <td>-0.921331</td>\n",
       "      <td>-0.723061</td>\n",
       "      <td>-0.657513</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-10</th>\n",
       "      <td>0.253044</td>\n",
       "      <td>-0.297883</td>\n",
       "      <td>-1.228556</td>\n",
       "      <td>1.034926</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-17</th>\n",
       "      <td>-0.220635</td>\n",
       "      <td>1.077651</td>\n",
       "      <td>-1.213702</td>\n",
       "      <td>-0.510470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-24</th>\n",
       "      <td>1.100897</td>\n",
       "      <td>-0.452336</td>\n",
       "      <td>-0.233467</td>\n",
       "      <td>-1.869192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-31</th>\n",
       "      <td>-0.277268</td>\n",
       "      <td>-0.057953</td>\n",
       "      <td>-0.759444</td>\n",
       "      <td>0.818167</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-06-07</th>\n",
       "      <td>0.475633</td>\n",
       "      <td>-0.732816</td>\n",
       "      <td>1.119707</td>\n",
       "      <td>0.193133</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-06-14</th>\n",
       "      <td>-0.869862</td>\n",
       "      <td>1.186251</td>\n",
       "      <td>0.212487</td>\n",
       "      <td>0.195008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-06-21</th>\n",
       "      <td>0.317783</td>\n",
       "      <td>-0.017249</td>\n",
       "      <td>1.223899</td>\n",
       "      <td>1.361316</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-06-28</th>\n",
       "      <td>0.732364</td>\n",
       "      <td>1.324168</td>\n",
       "      <td>0.795609</td>\n",
       "      <td>1.631651</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-07-05</th>\n",
       "      <td>0.222659</td>\n",
       "      <td>-1.059228</td>\n",
       "      <td>1.176284</td>\n",
       "      <td>0.050623</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-07-12</th>\n",
       "      <td>-1.350825</td>\n",
       "      <td>-0.274572</td>\n",
       "      <td>-0.136214</td>\n",
       "      <td>-1.176130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-07-19</th>\n",
       "      <td>-1.151187</td>\n",
       "      <td>1.335977</td>\n",
       "      <td>-0.632959</td>\n",
       "      <td>0.490485</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-07-26</th>\n",
       "      <td>-0.478664</td>\n",
       "      <td>2.045493</td>\n",
       "      <td>0.676500</td>\n",
       "      <td>0.755083</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-09</th>\n",
       "      <td>2.087661</td>\n",
       "      <td>0.838168</td>\n",
       "      <td>-1.032758</td>\n",
       "      <td>1.381013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-16</th>\n",
       "      <td>0.131040</td>\n",
       "      <td>-0.319778</td>\n",
       "      <td>-0.356118</td>\n",
       "      <td>1.014937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-23</th>\n",
       "      <td>0.028494</td>\n",
       "      <td>-0.172221</td>\n",
       "      <td>-0.286868</td>\n",
       "      <td>-0.955953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-30</th>\n",
       "      <td>0.080708</td>\n",
       "      <td>-0.014325</td>\n",
       "      <td>0.205696</td>\n",
       "      <td>0.271768</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-06-06</th>\n",
       "      <td>-0.388583</td>\n",
       "      <td>-0.078323</td>\n",
       "      <td>1.422937</td>\n",
       "      <td>0.668571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-06-13</th>\n",
       "      <td>-0.308196</td>\n",
       "      <td>0.499656</td>\n",
       "      <td>-0.761650</td>\n",
       "      <td>0.510194</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-06-20</th>\n",
       "      <td>-2.153853</td>\n",
       "      <td>-0.818067</td>\n",
       "      <td>0.018171</td>\n",
       "      <td>0.230707</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-06-27</th>\n",
       "      <td>1.305062</td>\n",
       "      <td>0.605385</td>\n",
       "      <td>2.039945</td>\n",
       "      <td>-0.301618</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-07-04</th>\n",
       "      <td>1.174659</td>\n",
       "      <td>0.658210</td>\n",
       "      <td>0.957964</td>\n",
       "      <td>1.134769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-07-11</th>\n",
       "      <td>2.075000</td>\n",
       "      <td>-0.533632</td>\n",
       "      <td>1.311475</td>\n",
       "      <td>-2.512404</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-07-18</th>\n",
       "      <td>1.225554</td>\n",
       "      <td>2.237374</td>\n",
       "      <td>1.314310</td>\n",
       "      <td>-0.031749</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-07-25</th>\n",
       "      <td>-0.065393</td>\n",
       "      <td>0.458851</td>\n",
       "      <td>-0.134822</td>\n",
       "      <td>-0.024065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-08-01</th>\n",
       "      <td>-0.330372</td>\n",
       "      <td>-0.527695</td>\n",
       "      <td>0.171576</td>\n",
       "      <td>-0.603213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-08-08</th>\n",
       "      <td>-0.063478</td>\n",
       "      <td>-1.110728</td>\n",
       "      <td>-0.170301</td>\n",
       "      <td>-0.453535</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-08-15</th>\n",
       "      <td>1.257497</td>\n",
       "      <td>0.051441</td>\n",
       "      <td>-1.382604</td>\n",
       "      <td>0.057552</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-08-22</th>\n",
       "      <td>-0.857474</td>\n",
       "      <td>0.239763</td>\n",
       "      <td>-1.456006</td>\n",
       "      <td>-0.348897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-08-29</th>\n",
       "      <td>-0.975273</td>\n",
       "      <td>0.240839</td>\n",
       "      <td>-0.374157</td>\n",
       "      <td>0.630248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-09-05</th>\n",
       "      <td>1.314031</td>\n",
       "      <td>-0.304986</td>\n",
       "      <td>0.592712</td>\n",
       "      <td>-0.011336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-09-12</th>\n",
       "      <td>-0.712210</td>\n",
       "      <td>-0.895643</td>\n",
       "      <td>0.417414</td>\n",
       "      <td>-0.141807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-09-19</th>\n",
       "      <td>1.956841</td>\n",
       "      <td>-0.571378</td>\n",
       "      <td>-0.197549</td>\n",
       "      <td>-0.876434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-09-26</th>\n",
       "      <td>-0.387675</td>\n",
       "      <td>-1.124718</td>\n",
       "      <td>0.927533</td>\n",
       "      <td>-0.593196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-10-03</th>\n",
       "      <td>0.860229</td>\n",
       "      <td>0.686119</td>\n",
       "      <td>0.425893</td>\n",
       "      <td>0.676995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-10-10</th>\n",
       "      <td>-1.555149</td>\n",
       "      <td>1.810324</td>\n",
       "      <td>0.064162</td>\n",
       "      <td>0.517637</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-10-17</th>\n",
       "      <td>2.095808</td>\n",
       "      <td>0.019846</td>\n",
       "      <td>0.141738</td>\n",
       "      <td>-0.169717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-10-24</th>\n",
       "      <td>0.944619</td>\n",
       "      <td>-0.119756</td>\n",
       "      <td>0.654905</td>\n",
       "      <td>1.089404</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-10-31</th>\n",
       "      <td>0.298400</td>\n",
       "      <td>1.418505</td>\n",
       "      <td>0.257235</td>\n",
       "      <td>1.133497</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-11-07</th>\n",
       "      <td>-0.241146</td>\n",
       "      <td>1.637815</td>\n",
       "      <td>0.451498</td>\n",
       "      <td>0.239312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-11-14</th>\n",
       "      <td>0.787298</td>\n",
       "      <td>-0.273724</td>\n",
       "      <td>0.454311</td>\n",
       "      <td>0.028949</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-11-21</th>\n",
       "      <td>0.336347</td>\n",
       "      <td>-0.591069</td>\n",
       "      <td>1.038792</td>\n",
       "      <td>-0.093430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-11-28</th>\n",
       "      <td>1.718558</td>\n",
       "      <td>-1.643689</td>\n",
       "      <td>0.878343</td>\n",
       "      <td>-1.513094</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas  New York      Ohio\n",
       "2000-01-05  0.178709 -0.436959  0.027527 -0.111819\n",
       "2000-01-12 -0.462057  0.312247 -0.750338 -1.281810\n",
       "2000-01-19 -0.604611 -0.542479 -0.129404  0.039914\n",
       "2000-01-26  1.008442 -0.400774 -0.553412 -2.735263\n",
       "2000-02-02 -1.069274 -1.173618 -0.098873 -0.885242\n",
       "2000-02-09  0.391516  0.792966 -0.938487 -0.656885\n",
       "2000-02-16 -0.809133  1.415891 -0.572519 -0.783915\n",
       "2000-02-23  0.114427  1.798014 -0.412250  0.087347\n",
       "2000-03-01 -0.070397  0.212633 -2.783785 -2.201481\n",
       "2000-03-08 -0.935894  0.631474  0.754077  0.424486\n",
       "2000-03-15 -0.105064  0.641382 -0.868503  0.779417\n",
       "2000-03-22 -0.634459 -1.756969 -0.687005  0.437763\n",
       "2000-03-29  1.190979  0.444920  0.309566  0.438933\n",
       "2000-04-05 -1.038103 -0.752969  0.333955  0.244031\n",
       "2000-04-12  0.179222  0.055535  0.044080  0.662187\n",
       "2000-04-19 -0.027065  0.307245 -0.687913 -0.816030\n",
       "2000-04-26 -1.010621 -0.439418 -0.527900 -0.124568\n",
       "2000-05-03 -0.005107 -0.921331 -0.723061 -0.657513\n",
       "2000-05-10  0.253044 -0.297883 -1.228556  1.034926\n",
       "2000-05-17 -0.220635  1.077651 -1.213702 -0.510470\n",
       "2000-05-24  1.100897 -0.452336 -0.233467 -1.869192\n",
       "2000-05-31 -0.277268 -0.057953 -0.759444  0.818167\n",
       "2000-06-07  0.475633 -0.732816  1.119707  0.193133\n",
       "2000-06-14 -0.869862  1.186251  0.212487  0.195008\n",
       "2000-06-21  0.317783 -0.017249  1.223899  1.361316\n",
       "2000-06-28  0.732364  1.324168  0.795609  1.631651\n",
       "2000-07-05  0.222659 -1.059228  1.176284  0.050623\n",
       "2000-07-12 -1.350825 -0.274572 -0.136214 -1.176130\n",
       "2000-07-19 -1.151187  1.335977 -0.632959  0.490485\n",
       "2000-07-26 -0.478664  2.045493  0.676500  0.755083\n",
       "...              ...       ...       ...       ...\n",
       "2001-05-09  2.087661  0.838168 -1.032758  1.381013\n",
       "2001-05-16  0.131040 -0.319778 -0.356118  1.014937\n",
       "2001-05-23  0.028494 -0.172221 -0.286868 -0.955953\n",
       "2001-05-30  0.080708 -0.014325  0.205696  0.271768\n",
       "2001-06-06 -0.388583 -0.078323  1.422937  0.668571\n",
       "2001-06-13 -0.308196  0.499656 -0.761650  0.510194\n",
       "2001-06-20 -2.153853 -0.818067  0.018171  0.230707\n",
       "2001-06-27  1.305062  0.605385  2.039945 -0.301618\n",
       "2001-07-04  1.174659  0.658210  0.957964  1.134769\n",
       "2001-07-11  2.075000 -0.533632  1.311475 -2.512404\n",
       "2001-07-18  1.225554  2.237374  1.314310 -0.031749\n",
       "2001-07-25 -0.065393  0.458851 -0.134822 -0.024065\n",
       "2001-08-01 -0.330372 -0.527695  0.171576 -0.603213\n",
       "2001-08-08 -0.063478 -1.110728 -0.170301 -0.453535\n",
       "2001-08-15  1.257497  0.051441 -1.382604  0.057552\n",
       "2001-08-22 -0.857474  0.239763 -1.456006 -0.348897\n",
       "2001-08-29 -0.975273  0.240839 -0.374157  0.630248\n",
       "2001-09-05  1.314031 -0.304986  0.592712 -0.011336\n",
       "2001-09-12 -0.712210 -0.895643  0.417414 -0.141807\n",
       "2001-09-19  1.956841 -0.571378 -0.197549 -0.876434\n",
       "2001-09-26 -0.387675 -1.124718  0.927533 -0.593196\n",
       "2001-10-03  0.860229  0.686119  0.425893  0.676995\n",
       "2001-10-10 -1.555149  1.810324  0.064162  0.517637\n",
       "2001-10-17  2.095808  0.019846  0.141738 -0.169717\n",
       "2001-10-24  0.944619 -0.119756  0.654905  1.089404\n",
       "2001-10-31  0.298400  1.418505  0.257235  1.133497\n",
       "2001-11-07 -0.241146  1.637815  0.451498  0.239312\n",
       "2001-11-14  0.787298 -0.273724  0.454311  0.028949\n",
       "2001-11-21  0.336347 -0.591069  1.038792 -0.093430\n",
       "2001-11-28  1.718558 -1.643689  0.878343 -1.513094\n",
       "\n",
       "[100 rows x 4 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "long_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>New York</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2001-05-02</th>\n",
       "      <td>1.013786</td>\n",
       "      <td>-0.991754</td>\n",
       "      <td>-0.226285</td>\n",
       "      <td>-0.651339</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-09</th>\n",
       "      <td>2.087661</td>\n",
       "      <td>0.838168</td>\n",
       "      <td>-1.032758</td>\n",
       "      <td>1.381013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-16</th>\n",
       "      <td>0.131040</td>\n",
       "      <td>-0.319778</td>\n",
       "      <td>-0.356118</td>\n",
       "      <td>1.014937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-23</th>\n",
       "      <td>0.028494</td>\n",
       "      <td>-0.172221</td>\n",
       "      <td>-0.286868</td>\n",
       "      <td>-0.955953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001-05-30</th>\n",
       "      <td>0.080708</td>\n",
       "      <td>-0.014325</td>\n",
       "      <td>0.205696</td>\n",
       "      <td>0.271768</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas  New York      Ohio\n",
       "2001-05-02  1.013786 -0.991754 -0.226285 -0.651339\n",
       "2001-05-09  2.087661  0.838168 -1.032758  1.381013\n",
       "2001-05-16  0.131040 -0.319778 -0.356118  1.014937\n",
       "2001-05-23  0.028494 -0.172221 -0.286868 -0.955953\n",
       "2001-05-30  0.080708 -0.014325  0.205696  0.271768"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "long_df.loc['2001-5']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [63]: dates = pd.DatetimeIndex(['1/1/2000', '1/2/2000',\n",
    "'1/2/2000',\n",
    "....: '1/2/2000', '1/3/2000'])\n",
    "In [64]: dup_ts = pd.Series(np.arange(5), index=dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01    0\n",
       "2000-01-02    1\n",
       "2000-01-02    2\n",
       "2000-01-02    3\n",
       "2000-01-03    4\n",
       "dtype: int32"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dup_ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dup_ts.index.is_unique"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dup_ts['2000-1-1']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-02    1\n",
       "2000-01-02    2\n",
       "2000-01-02    3\n",
       "dtype: int32"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dup_ts['2000-1-2']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "grounped = dup_ts.groupby(level=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01    0\n",
       "2000-01-02    2\n",
       "2000-01-03    4\n",
       "dtype: int32"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grounped.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01    0\n",
       "2000-01-02    6\n",
       "2000-01-03    4\n",
       "dtype: int32"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grounped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01    0\n",
       "2000-01-02    6\n",
       "2000-01-03    4\n",
       "dtype: int32"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grounped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011-01-02    0.681288\n",
       "2011-01-05   -0.165217\n",
       "2011-01-07   -0.957556\n",
       "2011-01-08    0.784220\n",
       "2011-01-10   -0.457118\n",
       "2011-01-12    1.050169\n",
       "dtype: float64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "resampler = ts.resample('D')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndexResampler [freq=<Day>, axis=0, closed=left, label=left, convention=start, base=0]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "resampler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "index = pd.date_range('2012-4-1','2012-6-1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-04-01', '2012-04-02', '2012-04-03', '2012-04-04',\n",
       "               '2012-04-05', '2012-04-06', '2012-04-07', '2012-04-08',\n",
       "               '2012-04-09', '2012-04-10', '2012-04-11', '2012-04-12',\n",
       "               '2012-04-13', '2012-04-14', '2012-04-15', '2012-04-16',\n",
       "               '2012-04-17', '2012-04-18', '2012-04-19', '2012-04-20',\n",
       "               '2012-04-21', '2012-04-22', '2012-04-23', '2012-04-24',\n",
       "               '2012-04-25', '2012-04-26', '2012-04-27', '2012-04-28',\n",
       "               '2012-04-29', '2012-04-30', '2012-05-01', '2012-05-02',\n",
       "               '2012-05-03', '2012-05-04', '2012-05-05', '2012-05-06',\n",
       "               '2012-05-07', '2012-05-08', '2012-05-09', '2012-05-10',\n",
       "               '2012-05-11', '2012-05-12', '2012-05-13', '2012-05-14',\n",
       "               '2012-05-15', '2012-05-16', '2012-05-17', '2012-05-18',\n",
       "               '2012-05-19', '2012-05-20', '2012-05-21', '2012-05-22',\n",
       "               '2012-05-23', '2012-05-24', '2012-05-25', '2012-05-26',\n",
       "               '2012-05-27', '2012-05-28', '2012-05-29', '2012-05-30',\n",
       "               '2012-05-31', '2012-06-01'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-04-01', '2012-04-02', '2012-04-03', '2012-04-04',\n",
       "               '2012-04-05', '2012-04-06', '2012-04-07', '2012-04-08',\n",
       "               '2012-04-09', '2012-04-10', '2012-04-11', '2012-04-12',\n",
       "               '2012-04-13', '2012-04-14', '2012-04-15', '2012-04-16',\n",
       "               '2012-04-17', '2012-04-18', '2012-04-19', '2012-04-20'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range(start='2012-4-1',periods=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2000-01-31', '2000-02-29', '2000-03-31', '2000-04-28',\n",
       "               '2000-05-31', '2000-06-30', '2000-07-31', '2000-08-31',\n",
       "               '2000-09-29', '2000-10-31', '2000-11-30'],\n",
       "              dtype='datetime64[ns]', freq='BM')"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2000-1-1','2000-12-1',freq='BM')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-05-02 12:56:31', '2012-05-03 12:56:31',\n",
       "               '2012-05-04 12:56:31', '2012-05-05 12:56:31',\n",
       "               '2012-05-06 12:56:31'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2012-05-02 12:56:31', periods=5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-05-02 00:00:00', '2012-05-02 01:00:00',\n",
       "               '2012-05-02 02:00:00', '2012-05-02 03:00:00',\n",
       "               '2012-05-02 04:00:00'],\n",
       "              dtype='datetime64[ns]', freq='H')"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2012-5-2 12:56:01',periods=5,normalize=True,freq='H')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pandas.tseries.offsets import Hour,Minute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [],
   "source": [
    "h = Hour()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Hour>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [],
   "source": [
    "h4 = Hour(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<4 * Hours>"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2000-01-01 00:00:00', '2000-01-01 04:00:00',\n",
       "               '2000-01-01 08:00:00', '2000-01-01 12:00:00',\n",
       "               '2000-01-01 16:00:00', '2000-01-01 20:00:00',\n",
       "               '2000-01-02 00:00:00', '2000-01-02 04:00:00',\n",
       "               '2000-01-02 08:00:00', '2000-01-02 12:00:00',\n",
       "               '2000-01-02 16:00:00', '2000-01-02 20:00:00',\n",
       "               '2000-01-03 00:00:00', '2000-01-03 04:00:00',\n",
       "               '2000-01-03 08:00:00', '2000-01-03 12:00:00',\n",
       "               '2000-01-03 16:00:00', '2000-01-03 20:00:00'],\n",
       "              dtype='datetime64[ns]', freq='4H')"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2000-1-1','2000-1-3 23:59',freq='4h')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<150 * Minutes>"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Hour(2)+Minute(30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2000-01-01 00:00:00', '2000-01-01 02:30:00',\n",
       "               '2000-01-01 05:00:00', '2000-01-01 07:30:00',\n",
       "               '2000-01-01 10:00:00', '2000-01-01 12:30:00',\n",
       "               '2000-01-01 15:00:00', '2000-01-01 17:30:00',\n",
       "               '2000-01-01 20:00:00', '2000-01-01 22:30:00'],\n",
       "              dtype='datetime64[ns]', freq='150T')"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2000-1-1',periods=10,freq='2h30min')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "rng = pd.date_range('2012-1-1','2012-9-1',freq='WOM-3FRI')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-01-20', '2012-02-17', '2012-03-16', '2012-04-20',\n",
       "               '2012-05-18', '2012-06-15', '2012-07-20', '2012-08-17'],\n",
       "              dtype='datetime64[ns]', freq='WOM-3FRI')"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [91]: ts = pd.Series(np.random.randn(4),\n",
    "....: index=pd.date_range('1/1/2000', periods=4,\n",
    "freq='M'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31    1.056532\n",
       "2000-02-29    0.023227\n",
       "2000-03-31    1.205217\n",
       "2000-04-30   -0.338408\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31         NaN\n",
       "2000-02-29         NaN\n",
       "2000-03-31    1.056532\n",
       "2000-04-30    0.023227\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.shift(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31    1.205217\n",
       "2000-02-29   -0.338408\n",
       "2000-03-31         NaN\n",
       "2000-04-30         NaN\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.shift(-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = pd.Series(range(10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    NaN\n",
       "1    1.0\n",
       "2    1.0\n",
       "3    1.0\n",
       "4    1.0\n",
       "5    1.0\n",
       "6    1.0\n",
       "7    1.0\n",
       "8    1.0\n",
       "9    1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s - s.shift(1) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31          NaN\n",
       "2000-02-29    -0.978016\n",
       "2000-03-31    50.888769\n",
       "2000-04-30    -1.280786\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts/ts.shift(1) - 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-03-31    1.056532\n",
       "2000-04-30    0.023227\n",
       "2000-05-31    1.205217\n",
       "2000-06-30   -0.338408\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.shift(2,freq='M')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-28    1.056532\n",
       "2000-02-26    0.023227\n",
       "2000-03-28    1.205217\n",
       "2000-04-27   -0.338408\n",
       "dtype: float64"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.shift(-3,freq='D')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pandas .tseries.offsets import Day,MonthEnd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [],
   "source": [
    "now = datetime.now()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2019-03-17 14:50:53.635484')"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now + Day(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2019-03-31 14:50:53.635484')"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now + MonthEnd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2019-04-30 14:50:53.635484')"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now + 2*MonthEnd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "offset = MonthEnd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2019-03-31 14:50:53.635484')"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "offset.rollforward(now)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2019-02-28 14:50:53.635484')"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "offset.rollback(now)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [106]: ts = pd.Series(np.random.randn(20),\n",
    ".....: index=pd.date_range('1/15/2000', periods=20,\n",
    "freq='4d'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-15    0.566011\n",
       "2000-01-19    0.100841\n",
       "2000-01-23   -0.754286\n",
       "2000-01-27   -0.957337\n",
       "2000-01-31    0.750691\n",
       "2000-02-04    1.038656\n",
       "2000-02-08    1.425730\n",
       "2000-02-12    0.449359\n",
       "2000-02-16   -0.967023\n",
       "2000-02-20    2.180013\n",
       "2000-02-24   -0.019441\n",
       "2000-02-28   -0.049138\n",
       "2000-03-03   -1.047417\n",
       "2000-03-07   -0.629100\n",
       "2000-03-11    0.606994\n",
       "2000-03-15   -0.140015\n",
       "2000-03-19   -0.483144\n",
       "2000-03-23   -0.249915\n",
       "2000-03-27   -1.117687\n",
       "2000-03-31    2.237080\n",
       "Freq: 4D, dtype: float64"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<MonthEnd>"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "offset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1999-12-31   -0.261193\n",
       "2000-01-31    0.601106\n",
       "2000-02-29   -0.437184\n",
       "2000-03-31    2.237080\n",
       "dtype: float64"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.groupby(offset.rollback).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31   -0.058816\n",
       "2000-02-29    0.579737\n",
       "2000-03-31   -0.102901\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.resample('M').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pytz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Africa/Abidjan',\n",
       " 'Africa/Accra',\n",
       " 'Africa/Addis_Ababa',\n",
       " 'Africa/Algiers',\n",
       " 'Africa/Asmara',\n",
       " 'Africa/Bamako',\n",
       " 'Africa/Bangui',\n",
       " 'Africa/Banjul',\n",
       " 'Africa/Bissau',\n",
       " 'Africa/Blantyre',\n",
       " 'Africa/Brazzaville',\n",
       " 'Africa/Bujumbura',\n",
       " 'Africa/Cairo',\n",
       " 'Africa/Casablanca',\n",
       " 'Africa/Ceuta',\n",
       " 'Africa/Conakry',\n",
       " 'Africa/Dakar',\n",
       " 'Africa/Dar_es_Salaam',\n",
       " 'Africa/Djibouti',\n",
       " 'Africa/Douala',\n",
       " 'Africa/El_Aaiun',\n",
       " 'Africa/Freetown',\n",
       " 'Africa/Gaborone',\n",
       " 'Africa/Harare',\n",
       " 'Africa/Johannesburg',\n",
       " 'Africa/Juba',\n",
       " 'Africa/Kampala',\n",
       " 'Africa/Khartoum',\n",
       " 'Africa/Kigali',\n",
       " 'Africa/Kinshasa',\n",
       " 'Africa/Lagos',\n",
       " 'Africa/Libreville',\n",
       " 'Africa/Lome',\n",
       " 'Africa/Luanda',\n",
       " 'Africa/Lubumbashi',\n",
       " 'Africa/Lusaka',\n",
       " 'Africa/Malabo',\n",
       " 'Africa/Maputo',\n",
       " 'Africa/Maseru',\n",
       " 'Africa/Mbabane',\n",
       " 'Africa/Mogadishu',\n",
       " 'Africa/Monrovia',\n",
       " 'Africa/Nairobi',\n",
       " 'Africa/Ndjamena',\n",
       " 'Africa/Niamey',\n",
       " 'Africa/Nouakchott',\n",
       " 'Africa/Ouagadougou',\n",
       " 'Africa/Porto-Novo',\n",
       " 'Africa/Sao_Tome',\n",
       " 'Africa/Tripoli',\n",
       " 'Africa/Tunis',\n",
       " 'Africa/Windhoek',\n",
       " 'America/Adak',\n",
       " 'America/Anchorage',\n",
       " 'America/Anguilla',\n",
       " 'America/Antigua',\n",
       " 'America/Araguaina',\n",
       " 'America/Argentina/Buenos_Aires',\n",
       " 'America/Argentina/Catamarca',\n",
       " 'America/Argentina/Cordoba',\n",
       " 'America/Argentina/Jujuy',\n",
       " 'America/Argentina/La_Rioja',\n",
       " 'America/Argentina/Mendoza',\n",
       " 'America/Argentina/Rio_Gallegos',\n",
       " 'America/Argentina/Salta',\n",
       " 'America/Argentina/San_Juan',\n",
       " 'America/Argentina/San_Luis',\n",
       " 'America/Argentina/Tucuman',\n",
       " 'America/Argentina/Ushuaia',\n",
       " 'America/Aruba',\n",
       " 'America/Asuncion',\n",
       " 'America/Atikokan',\n",
       " 'America/Bahia',\n",
       " 'America/Bahia_Banderas',\n",
       " 'America/Barbados',\n",
       " 'America/Belem',\n",
       " 'America/Belize',\n",
       " 'America/Blanc-Sablon',\n",
       " 'America/Boa_Vista',\n",
       " 'America/Bogota',\n",
       " 'America/Boise',\n",
       " 'America/Cambridge_Bay',\n",
       " 'America/Campo_Grande',\n",
       " 'America/Cancun',\n",
       " 'America/Caracas',\n",
       " 'America/Cayenne',\n",
       " 'America/Cayman',\n",
       " 'America/Chicago',\n",
       " 'America/Chihuahua',\n",
       " 'America/Costa_Rica',\n",
       " 'America/Creston',\n",
       " 'America/Cuiaba',\n",
       " 'America/Curacao',\n",
       " 'America/Danmarkshavn',\n",
       " 'America/Dawson',\n",
       " 'America/Dawson_Creek',\n",
       " 'America/Denver',\n",
       " 'America/Detroit',\n",
       " 'America/Dominica',\n",
       " 'America/Edmonton',\n",
       " 'America/Eirunepe',\n",
       " 'America/El_Salvador',\n",
       " 'America/Fort_Nelson',\n",
       " 'America/Fortaleza',\n",
       " 'America/Glace_Bay',\n",
       " 'America/Godthab',\n",
       " 'America/Goose_Bay',\n",
       " 'America/Grand_Turk',\n",
       " 'America/Grenada',\n",
       " 'America/Guadeloupe',\n",
       " 'America/Guatemala',\n",
       " 'America/Guayaquil',\n",
       " 'America/Guyana',\n",
       " 'America/Halifax',\n",
       " 'America/Havana',\n",
       " 'America/Hermosillo',\n",
       " 'America/Indiana/Indianapolis',\n",
       " 'America/Indiana/Knox',\n",
       " 'America/Indiana/Marengo',\n",
       " 'America/Indiana/Petersburg',\n",
       " 'America/Indiana/Tell_City',\n",
       " 'America/Indiana/Vevay',\n",
       " 'America/Indiana/Vincennes',\n",
       " 'America/Indiana/Winamac',\n",
       " 'America/Inuvik',\n",
       " 'America/Iqaluit',\n",
       " 'America/Jamaica',\n",
       " 'America/Juneau',\n",
       " 'America/Kentucky/Louisville',\n",
       " 'America/Kentucky/Monticello',\n",
       " 'America/Kralendijk',\n",
       " 'America/La_Paz',\n",
       " 'America/Lima',\n",
       " 'America/Los_Angeles',\n",
       " 'America/Lower_Princes',\n",
       " 'America/Maceio',\n",
       " 'America/Managua',\n",
       " 'America/Manaus',\n",
       " 'America/Marigot',\n",
       " 'America/Martinique',\n",
       " 'America/Matamoros',\n",
       " 'America/Mazatlan',\n",
       " 'America/Menominee',\n",
       " 'America/Merida',\n",
       " 'America/Metlakatla',\n",
       " 'America/Mexico_City',\n",
       " 'America/Miquelon',\n",
       " 'America/Moncton',\n",
       " 'America/Monterrey',\n",
       " 'America/Montevideo',\n",
       " 'America/Montserrat',\n",
       " 'America/Nassau',\n",
       " 'America/New_York',\n",
       " 'America/Nipigon',\n",
       " 'America/Nome',\n",
       " 'America/Noronha',\n",
       " 'America/North_Dakota/Beulah',\n",
       " 'America/North_Dakota/Center',\n",
       " 'America/North_Dakota/New_Salem',\n",
       " 'America/Ojinaga',\n",
       " 'America/Panama',\n",
       " 'America/Pangnirtung',\n",
       " 'America/Paramaribo',\n",
       " 'America/Phoenix',\n",
       " 'America/Port-au-Prince',\n",
       " 'America/Port_of_Spain',\n",
       " 'America/Porto_Velho',\n",
       " 'America/Puerto_Rico',\n",
       " 'America/Punta_Arenas',\n",
       " 'America/Rainy_River',\n",
       " 'America/Rankin_Inlet',\n",
       " 'America/Recife',\n",
       " 'America/Regina',\n",
       " 'America/Resolute',\n",
       " 'America/Rio_Branco',\n",
       " 'America/Santarem',\n",
       " 'America/Santiago',\n",
       " 'America/Santo_Domingo',\n",
       " 'America/Sao_Paulo',\n",
       " 'America/Scoresbysund',\n",
       " 'America/Sitka',\n",
       " 'America/St_Barthelemy',\n",
       " 'America/St_Johns',\n",
       " 'America/St_Kitts',\n",
       " 'America/St_Lucia',\n",
       " 'America/St_Thomas',\n",
       " 'America/St_Vincent',\n",
       " 'America/Swift_Current',\n",
       " 'America/Tegucigalpa',\n",
       " 'America/Thule',\n",
       " 'America/Thunder_Bay',\n",
       " 'America/Tijuana',\n",
       " 'America/Toronto',\n",
       " 'America/Tortola',\n",
       " 'America/Vancouver',\n",
       " 'America/Whitehorse',\n",
       " 'America/Winnipeg',\n",
       " 'America/Yakutat',\n",
       " 'America/Yellowknife',\n",
       " 'Antarctica/Casey',\n",
       " 'Antarctica/Davis',\n",
       " 'Antarctica/DumontDUrville',\n",
       " 'Antarctica/Macquarie',\n",
       " 'Antarctica/Mawson',\n",
       " 'Antarctica/McMurdo',\n",
       " 'Antarctica/Palmer',\n",
       " 'Antarctica/Rothera',\n",
       " 'Antarctica/Syowa',\n",
       " 'Antarctica/Troll',\n",
       " 'Antarctica/Vostok',\n",
       " 'Arctic/Longyearbyen',\n",
       " 'Asia/Aden',\n",
       " 'Asia/Almaty',\n",
       " 'Asia/Amman',\n",
       " 'Asia/Anadyr',\n",
       " 'Asia/Aqtau',\n",
       " 'Asia/Aqtobe',\n",
       " 'Asia/Ashgabat',\n",
       " 'Asia/Atyrau',\n",
       " 'Asia/Baghdad',\n",
       " 'Asia/Bahrain',\n",
       " 'Asia/Baku',\n",
       " 'Asia/Bangkok',\n",
       " 'Asia/Barnaul',\n",
       " 'Asia/Beirut',\n",
       " 'Asia/Bishkek',\n",
       " 'Asia/Brunei',\n",
       " 'Asia/Chita',\n",
       " 'Asia/Choibalsan',\n",
       " 'Asia/Colombo',\n",
       " 'Asia/Damascus',\n",
       " 'Asia/Dhaka',\n",
       " 'Asia/Dili',\n",
       " 'Asia/Dubai',\n",
       " 'Asia/Dushanbe',\n",
       " 'Asia/Famagusta',\n",
       " 'Asia/Gaza',\n",
       " 'Asia/Hebron',\n",
       " 'Asia/Ho_Chi_Minh',\n",
       " 'Asia/Hong_Kong',\n",
       " 'Asia/Hovd',\n",
       " 'Asia/Irkutsk',\n",
       " 'Asia/Jakarta',\n",
       " 'Asia/Jayapura',\n",
       " 'Asia/Jerusalem',\n",
       " 'Asia/Kabul',\n",
       " 'Asia/Kamchatka',\n",
       " 'Asia/Karachi',\n",
       " 'Asia/Kathmandu',\n",
       " 'Asia/Khandyga',\n",
       " 'Asia/Kolkata',\n",
       " 'Asia/Krasnoyarsk',\n",
       " 'Asia/Kuala_Lumpur',\n",
       " 'Asia/Kuching',\n",
       " 'Asia/Kuwait',\n",
       " 'Asia/Macau',\n",
       " 'Asia/Magadan',\n",
       " 'Asia/Makassar',\n",
       " 'Asia/Manila',\n",
       " 'Asia/Muscat',\n",
       " 'Asia/Nicosia',\n",
       " 'Asia/Novokuznetsk',\n",
       " 'Asia/Novosibirsk',\n",
       " 'Asia/Omsk',\n",
       " 'Asia/Oral',\n",
       " 'Asia/Phnom_Penh',\n",
       " 'Asia/Pontianak',\n",
       " 'Asia/Pyongyang',\n",
       " 'Asia/Qatar',\n",
       " 'Asia/Qyzylorda',\n",
       " 'Asia/Riyadh',\n",
       " 'Asia/Sakhalin',\n",
       " 'Asia/Samarkand',\n",
       " 'Asia/Seoul',\n",
       " 'Asia/Shanghai',\n",
       " 'Asia/Singapore',\n",
       " 'Asia/Srednekolymsk',\n",
       " 'Asia/Taipei',\n",
       " 'Asia/Tashkent',\n",
       " 'Asia/Tbilisi',\n",
       " 'Asia/Tehran',\n",
       " 'Asia/Thimphu',\n",
       " 'Asia/Tokyo',\n",
       " 'Asia/Tomsk',\n",
       " 'Asia/Ulaanbaatar',\n",
       " 'Asia/Urumqi',\n",
       " 'Asia/Ust-Nera',\n",
       " 'Asia/Vientiane',\n",
       " 'Asia/Vladivostok',\n",
       " 'Asia/Yakutsk',\n",
       " 'Asia/Yangon',\n",
       " 'Asia/Yekaterinburg',\n",
       " 'Asia/Yerevan',\n",
       " 'Atlantic/Azores',\n",
       " 'Atlantic/Bermuda',\n",
       " 'Atlantic/Canary',\n",
       " 'Atlantic/Cape_Verde',\n",
       " 'Atlantic/Faroe',\n",
       " 'Atlantic/Madeira',\n",
       " 'Atlantic/Reykjavik',\n",
       " 'Atlantic/South_Georgia',\n",
       " 'Atlantic/St_Helena',\n",
       " 'Atlantic/Stanley',\n",
       " 'Australia/Adelaide',\n",
       " 'Australia/Brisbane',\n",
       " 'Australia/Broken_Hill',\n",
       " 'Australia/Currie',\n",
       " 'Australia/Darwin',\n",
       " 'Australia/Eucla',\n",
       " 'Australia/Hobart',\n",
       " 'Australia/Lindeman',\n",
       " 'Australia/Lord_Howe',\n",
       " 'Australia/Melbourne',\n",
       " 'Australia/Perth',\n",
       " 'Australia/Sydney',\n",
       " 'Canada/Atlantic',\n",
       " 'Canada/Central',\n",
       " 'Canada/Eastern',\n",
       " 'Canada/Mountain',\n",
       " 'Canada/Newfoundland',\n",
       " 'Canada/Pacific',\n",
       " 'Europe/Amsterdam',\n",
       " 'Europe/Andorra',\n",
       " 'Europe/Astrakhan',\n",
       " 'Europe/Athens',\n",
       " 'Europe/Belgrade',\n",
       " 'Europe/Berlin',\n",
       " 'Europe/Bratislava',\n",
       " 'Europe/Brussels',\n",
       " 'Europe/Bucharest',\n",
       " 'Europe/Budapest',\n",
       " 'Europe/Busingen',\n",
       " 'Europe/Chisinau',\n",
       " 'Europe/Copenhagen',\n",
       " 'Europe/Dublin',\n",
       " 'Europe/Gibraltar',\n",
       " 'Europe/Guernsey',\n",
       " 'Europe/Helsinki',\n",
       " 'Europe/Isle_of_Man',\n",
       " 'Europe/Istanbul',\n",
       " 'Europe/Jersey',\n",
       " 'Europe/Kaliningrad',\n",
       " 'Europe/Kiev',\n",
       " 'Europe/Kirov',\n",
       " 'Europe/Lisbon',\n",
       " 'Europe/Ljubljana',\n",
       " 'Europe/London',\n",
       " 'Europe/Luxembourg',\n",
       " 'Europe/Madrid',\n",
       " 'Europe/Malta',\n",
       " 'Europe/Mariehamn',\n",
       " 'Europe/Minsk',\n",
       " 'Europe/Monaco',\n",
       " 'Europe/Moscow',\n",
       " 'Europe/Oslo',\n",
       " 'Europe/Paris',\n",
       " 'Europe/Podgorica',\n",
       " 'Europe/Prague',\n",
       " 'Europe/Riga',\n",
       " 'Europe/Rome',\n",
       " 'Europe/Samara',\n",
       " 'Europe/San_Marino',\n",
       " 'Europe/Sarajevo',\n",
       " 'Europe/Saratov',\n",
       " 'Europe/Simferopol',\n",
       " 'Europe/Skopje',\n",
       " 'Europe/Sofia',\n",
       " 'Europe/Stockholm',\n",
       " 'Europe/Tallinn',\n",
       " 'Europe/Tirane',\n",
       " 'Europe/Ulyanovsk',\n",
       " 'Europe/Uzhgorod',\n",
       " 'Europe/Vaduz',\n",
       " 'Europe/Vatican',\n",
       " 'Europe/Vienna',\n",
       " 'Europe/Vilnius',\n",
       " 'Europe/Volgograd',\n",
       " 'Europe/Warsaw',\n",
       " 'Europe/Zagreb',\n",
       " 'Europe/Zaporozhye',\n",
       " 'Europe/Zurich',\n",
       " 'GMT',\n",
       " 'Indian/Antananarivo',\n",
       " 'Indian/Chagos',\n",
       " 'Indian/Christmas',\n",
       " 'Indian/Cocos',\n",
       " 'Indian/Comoro',\n",
       " 'Indian/Kerguelen',\n",
       " 'Indian/Mahe',\n",
       " 'Indian/Maldives',\n",
       " 'Indian/Mauritius',\n",
       " 'Indian/Mayotte',\n",
       " 'Indian/Reunion',\n",
       " 'Pacific/Apia',\n",
       " 'Pacific/Auckland',\n",
       " 'Pacific/Bougainville',\n",
       " 'Pacific/Chatham',\n",
       " 'Pacific/Chuuk',\n",
       " 'Pacific/Easter',\n",
       " 'Pacific/Efate',\n",
       " 'Pacific/Enderbury',\n",
       " 'Pacific/Fakaofo',\n",
       " 'Pacific/Fiji',\n",
       " 'Pacific/Funafuti',\n",
       " 'Pacific/Galapagos',\n",
       " 'Pacific/Gambier',\n",
       " 'Pacific/Guadalcanal',\n",
       " 'Pacific/Guam',\n",
       " 'Pacific/Honolulu',\n",
       " 'Pacific/Kiritimati',\n",
       " 'Pacific/Kosrae',\n",
       " 'Pacific/Kwajalein',\n",
       " 'Pacific/Majuro',\n",
       " 'Pacific/Marquesas',\n",
       " 'Pacific/Midway',\n",
       " 'Pacific/Nauru',\n",
       " 'Pacific/Niue',\n",
       " 'Pacific/Norfolk',\n",
       " 'Pacific/Noumea',\n",
       " 'Pacific/Pago_Pago',\n",
       " 'Pacific/Palau',\n",
       " 'Pacific/Pitcairn',\n",
       " 'Pacific/Pohnpei',\n",
       " 'Pacific/Port_Moresby',\n",
       " 'Pacific/Rarotonga',\n",
       " 'Pacific/Saipan',\n",
       " 'Pacific/Tahiti',\n",
       " 'Pacific/Tarawa',\n",
       " 'Pacific/Tongatapu',\n",
       " 'Pacific/Wake',\n",
       " 'Pacific/Wallis',\n",
       " 'US/Alaska',\n",
       " 'US/Arizona',\n",
       " 'US/Central',\n",
       " 'US/Eastern',\n",
       " 'US/Hawaii',\n",
       " 'US/Mountain',\n",
       " 'US/Pacific',\n",
       " 'UTC']"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pytz.common_timezones"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [],
   "source": [
    "tz = pytz.timezone('Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 09:30:00   -0.333308\n",
       "2012-03-10 09:30:00   -0.833606\n",
       "2012-03-11 09:30:00    0.113813\n",
       "2012-03-12 09:30:00    0.113575\n",
       "2012-03-13 09:30:00   -0.366373\n",
       "2012-03-14 09:30:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [114]: rng = pd.date_range('3/9/2012 9:30', periods=6, freq='D')\n",
    "In [115]: ts = pd.Series(np.random.randn(len(rng)), index=rng)\n",
    "In [116]: ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(ts.index.tz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00+00:00', '2012-03-10 09:30:00+00:00',\n",
       "               '2012-03-11 09:30:00+00:00', '2012-03-12 09:30:00+00:00',\n",
       "               '2012-03-13 09:30:00+00:00', '2012-03-14 09:30:00+00:00',\n",
       "               '2012-03-15 09:30:00+00:00', '2012-03-16 09:30:00+00:00',\n",
       "               '2012-03-17 09:30:00+00:00', '2012-03-18 09:30:00+00:00'],\n",
       "              dtype='datetime64[ns, UTC]', freq='D')"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('3/9/2012 9:30', periods=10, freq='D',\n",
    "tz='UTC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 09:30:00   -0.333308\n",
       "2012-03-10 09:30:00   -0.833606\n",
       "2012-03-11 09:30:00    0.113813\n",
       "2012-03-12 09:30:00    0.113575\n",
       "2012-03-13 09:30:00   -0.366373\n",
       "2012-03-14 09:30:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts_utc = ts.tz_localize('UTC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 09:30:00+00:00   -0.333308\n",
       "2012-03-10 09:30:00+00:00   -0.833606\n",
       "2012-03-11 09:30:00+00:00    0.113813\n",
       "2012-03-12 09:30:00+00:00    0.113575\n",
       "2012-03-13 09:30:00+00:00   -0.366373\n",
       "2012-03-14 09:30:00+00:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_utc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2012-03-09 09:30:00+00:00', '2012-03-10 09:30:00+00:00',\n",
       "               '2012-03-11 09:30:00+00:00', '2012-03-12 09:30:00+00:00',\n",
       "               '2012-03-13 09:30:00+00:00', '2012-03-14 09:30:00+00:00'],\n",
       "              dtype='datetime64[ns, UTC]', freq='D')"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_utc.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 17:30:00+08:00   -0.333308\n",
       "2012-03-10 17:30:00+08:00   -0.833606\n",
       "2012-03-11 17:30:00+08:00    0.113813\n",
       "2012-03-12 17:30:00+08:00    0.113575\n",
       "2012-03-13 17:30:00+08:00   -0.366373\n",
       "2012-03-14 17:30:00+08:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_utc.tz_convert('Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [124]: ts_eastern = ts.tz_localize('America/New_York')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 14:30:00+00:00   -0.333308\n",
       "2012-03-10 14:30:00+00:00   -0.833606\n",
       "2012-03-11 13:30:00+00:00    0.113813\n",
       "2012-03-12 13:30:00+00:00    0.113575\n",
       "2012-03-13 13:30:00+00:00   -0.366373\n",
       "2012-03-14 13:30:00+00:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_eastern.tz_convert('UTC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-09 22:30:00+08:00   -0.333308\n",
       "2012-03-10 22:30:00+08:00   -0.833606\n",
       "2012-03-11 21:30:00+08:00    0.113813\n",
       "2012-03-12 21:30:00+08:00    0.113575\n",
       "2012-03-13 21:30:00+08:00   -0.366373\n",
       "2012-03-14 21:30:00+08:00   -1.518365\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts_eastern.tz_convert('Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [],
   "source": [
    "stamp = pd.Timestamp('2011-3-12 4:00')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [],
   "source": [
    "stamp_utc = stamp.tz_localize('utc')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2011-03-12 12:00:00+0800', tz='Asia/Shanghai')"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp_utc.tz_convert('Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [],
   "source": [
    "stamp_moscow = pd.Timestamp('2011-3-12 4:00',tz='Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2011-03-12 04:00:00+0800', tz='Asia/Shanghai')"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp_moscow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1299902400000000000"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp_utc.value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2013-03-11 09:30:00-0400', tz='US/Eastern')"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pandas.tseries.offsets import Hour\n",
    "stamp = pd.Timestamp('2013-03-11 09:30', tz='US/Eastern')\n",
    "stamp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2013-03-11 12:30:00-0400', tz='US/Eastern')"
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp + Hour(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2012-11-04 00:30:00-0400', tz='US/Eastern')"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [139]: stamp = pd.Timestamp('2012-11-04 00:30', tz='US/Eastern')\n",
    "In [140]: stamp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2012-11-04 01:30:00-0500', tz='US/Eastern')"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stamp + 2*Hour()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-07 09:30:00   -0.259024\n",
       "2012-03-08 09:30:00    1.246461\n",
       "2012-03-09 09:30:00    0.149440\n",
       "2012-03-12 09:30:00   -0.352030\n",
       "2012-03-13 09:30:00   -0.052141\n",
       "2012-03-14 09:30:00   -0.603305\n",
       "2012-03-15 09:30:00   -1.182910\n",
       "2012-03-16 09:30:00    0.002142\n",
       "2012-03-19 09:30:00    0.148180\n",
       "2012-03-20 09:30:00    0.410001\n",
       "Freq: B, dtype: float64"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [142]: rng = pd.date_range('3/7/2012 9:30', periods=10, freq='B')\n",
    "In [143]: ts = pd.Series(np.random.randn(len(rng)), index=rng)\n",
    "In [144]: ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [145]: ts1 = ts[:7].tz_localize('Europe/London')\n",
    "In [146]: ts2 = ts1[2:].tz_convert('Europe/Moscow')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-03-07 09:30:00+00:00         NaN\n",
       "2012-03-08 09:30:00+00:00         NaN\n",
       "2012-03-09 09:30:00+00:00    0.298881\n",
       "2012-03-12 09:30:00+00:00   -0.704061\n",
       "2012-03-13 09:30:00+00:00   -0.104282\n",
       "2012-03-14 09:30:00+00:00   -1.206611\n",
       "2012-03-15 09:30:00+00:00   -2.365820\n",
       "Freq: B, dtype: float64"
      ]
     },
     "execution_count": 157,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts1 + ts2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = pd.Period(2007,freq='A-DEC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007', 'A-DEC')"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2012', 'A-DEC')"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p+5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2005', 'A-DEC')"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 162,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Period('2014', freq='A-DEC') - p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [],
   "source": [
    "rng = pd.period_range('2000-1-1','2000-6-30',freq='M')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2000-01', '2000-02', '2000-03', '2000-04', '2000-05', '2000-06'], dtype='period[M]', freq='M')"
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01    0.656115\n",
       "2000-02    0.988989\n",
       "2000-03    0.420790\n",
       "2000-04   -0.089476\n",
       "2000-05    0.281353\n",
       "2000-06    1.622188\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(np.random.randn(6), index=rng)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [],
   "source": [
    "values = ['2001Q3', '2002Q2', '2003Q1']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [],
   "source": [
    "index = pd.PeriodIndex(values,freq='Q-DEC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2001Q3', '2002Q2', '2003Q1'], dtype='period[Q-DEC]', freq='Q-DEC')"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = pd.Period('2007',freq='A-DEC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007', 'A-DEC')"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007-01', 'M')"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('M',how='start')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007-12-31', 'D')"
      ]
     },
     "execution_count": 175,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('D',how='end')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = pd.Period('2007', freq='A-JUN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007', 'A-JUN')"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2006-07', 'M')"
      ]
     },
     "execution_count": 178,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('M','start')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2007-06', 'M')"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('M','end')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = pd.Period('2007-7','M')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2008', 'A-JUN')"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('A-JUN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "metadata": {},
   "outputs": [],
   "source": [
    "rng = pd.period_range('2006', '2009', freq='A-DEC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts = pd.Series(np.random.randn(len(rng)), index=rng)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2006', '2007', '2008', '2009'], dtype='period[A-DEC]', freq='A-DEC')"
      ]
     },
     "execution_count": 191,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2006   -0.904183\n",
       "2007   -0.474789\n",
       "2008    1.070779\n",
       "2009    0.284888\n",
       "Freq: A-DEC, dtype: float64"
      ]
     },
     "execution_count": 192,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2006-01   -0.904183\n",
       "2007-01   -0.474789\n",
       "2008-01    1.070779\n",
       "2009-01    0.284888\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 193,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.asfreq('M',how='start')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2006-12-29   -0.904183\n",
       "2007-12-31   -0.474789\n",
       "2008-12-31    1.070779\n",
       "2009-12-31    0.284888\n",
       "Freq: B, dtype: float64"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.asfreq('B',how='END')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = pd.Period('2013Q4',freq='Q-JAN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2013Q4', 'Q-JAN')"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2012-11-01', 'D')"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('D','start')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2013-01-31', 'D')"
      ]
     },
     "execution_count": 198,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p.asfreq('D','end')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2013-01-30 16:00:00')"
      ]
     },
     "execution_count": 203,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((p.asfreq('d','e') - 1).asfreq('T','s') + 16*60).to_timestamp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [],
   "source": [
    " rng = pd.period_range('2011Q3', '2012Q4', freq='Q-JAN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2011Q3', '2011Q4', '2012Q1', '2012Q2', '2012Q3', '2012Q4'], dtype='period[Q-JAN]', freq='Q-JAN')"
      ]
     },
     "execution_count": 205,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2011Q3    0\n",
       "2011Q4    1\n",
       "2012Q1    2\n",
       "2012Q2    3\n",
       "2012Q3    4\n",
       "2012Q4    5\n",
       "Freq: Q-JAN, dtype: int32"
      ]
     },
     "execution_count": 207,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " ts = pd.Series(np.arange(len(rng)), index=rng)\n",
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "metadata": {},
   "outputs": [],
   "source": [
    "new_rng = (rng.asfreq('B', 'e') - 1).asfreq('T', 's') + 16* 60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts.index = new_rng.to_timestamp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 211,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2010-10-28 16:00:00    0\n",
       "2011-01-28 16:00:00    1\n",
       "2011-04-28 16:00:00    2\n",
       "2011-07-28 16:00:00    3\n",
       "2011-10-28 16:00:00    4\n",
       "2012-01-30 16:00:00    5\n",
       "dtype: int32"
      ]
     },
     "execution_count": 211,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 212,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31    0.083488\n",
       "2000-02-29    0.052317\n",
       "2000-03-31   -0.209663\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 212,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [188]: rng = pd.date_range('2000-01-01', periods=3, freq='M')\n",
    "In [189]: ts = pd.Series(np.random.randn(3), index=rng)\n",
    "In [190]: ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "metadata": {},
   "outputs": [],
   "source": [
    "pts = ts.to_period()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01    0.083488\n",
       "2000-02    0.052317\n",
       "2000-03   -0.209663\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 216,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-29   -0.397315\n",
       "2000-01-30   -0.310497\n",
       "2000-01-31   -0.436449\n",
       "2000-02-01    0.599124\n",
       "2000-02-02    0.269980\n",
       "2000-02-03   -0.452068\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 216,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [193]: rng = pd.date_range('1/29/2000', periods=6, freq='D')\n",
    "In [194]: ts2 = pd.Series(np.random.randn(6), index=rng)\n",
    "In [195]: ts2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 217,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01   -0.397315\n",
       "2000-01   -0.310497\n",
       "2000-01   -0.436449\n",
       "2000-02    0.599124\n",
       "2000-02    0.269980\n",
       "2000-02   -0.452068\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 217,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts2.to_period('M')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 219,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01   -0.397315\n",
       "2000-01-01   -0.310497\n",
       "2000-01-01   -0.436449\n",
       "2000-02-01    0.599124\n",
       "2000-02-01    0.269980\n",
       "2000-02-01   -0.452068\n",
       "dtype: float64"
      ]
     },
     "execution_count": 219,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts2.to_period('M').to_timestamp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 220,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>quarter</th>\n",
       "      <th>realgdp</th>\n",
       "      <th>realcons</th>\n",
       "      <th>realinv</th>\n",
       "      <th>realgovt</th>\n",
       "      <th>realdpi</th>\n",
       "      <th>cpi</th>\n",
       "      <th>m1</th>\n",
       "      <th>tbilrate</th>\n",
       "      <th>unemp</th>\n",
       "      <th>pop</th>\n",
       "      <th>infl</th>\n",
       "      <th>realint</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2710.349</td>\n",
       "      <td>1707.4</td>\n",
       "      <td>286.898</td>\n",
       "      <td>470.045</td>\n",
       "      <td>1886.9</td>\n",
       "      <td>28.98</td>\n",
       "      <td>139.7</td>\n",
       "      <td>2.82</td>\n",
       "      <td>5.8</td>\n",
       "      <td>177.146</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2778.801</td>\n",
       "      <td>1733.7</td>\n",
       "      <td>310.859</td>\n",
       "      <td>481.301</td>\n",
       "      <td>1919.7</td>\n",
       "      <td>29.15</td>\n",
       "      <td>141.7</td>\n",
       "      <td>3.08</td>\n",
       "      <td>5.1</td>\n",
       "      <td>177.830</td>\n",
       "      <td>2.34</td>\n",
       "      <td>0.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2775.488</td>\n",
       "      <td>1751.8</td>\n",
       "      <td>289.226</td>\n",
       "      <td>491.260</td>\n",
       "      <td>1916.4</td>\n",
       "      <td>29.35</td>\n",
       "      <td>140.5</td>\n",
       "      <td>3.82</td>\n",
       "      <td>5.3</td>\n",
       "      <td>178.657</td>\n",
       "      <td>2.74</td>\n",
       "      <td>1.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2785.204</td>\n",
       "      <td>1753.7</td>\n",
       "      <td>299.356</td>\n",
       "      <td>484.052</td>\n",
       "      <td>1931.3</td>\n",
       "      <td>29.37</td>\n",
       "      <td>140.0</td>\n",
       "      <td>4.33</td>\n",
       "      <td>5.6</td>\n",
       "      <td>179.386</td>\n",
       "      <td>0.27</td>\n",
       "      <td>4.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1960.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2847.699</td>\n",
       "      <td>1770.5</td>\n",
       "      <td>331.722</td>\n",
       "      <td>462.199</td>\n",
       "      <td>1955.5</td>\n",
       "      <td>29.54</td>\n",
       "      <td>139.6</td>\n",
       "      <td>3.50</td>\n",
       "      <td>5.2</td>\n",
       "      <td>180.007</td>\n",
       "      <td>2.31</td>\n",
       "      <td>1.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     year  quarter   realgdp  realcons  realinv  realgovt  realdpi    cpi  \\\n",
       "0  1959.0      1.0  2710.349    1707.4  286.898   470.045   1886.9  28.98   \n",
       "1  1959.0      2.0  2778.801    1733.7  310.859   481.301   1919.7  29.15   \n",
       "2  1959.0      3.0  2775.488    1751.8  289.226   491.260   1916.4  29.35   \n",
       "3  1959.0      4.0  2785.204    1753.7  299.356   484.052   1931.3  29.37   \n",
       "4  1960.0      1.0  2847.699    1770.5  331.722   462.199   1955.5  29.54   \n",
       "\n",
       "      m1  tbilrate  unemp      pop  infl  realint  \n",
       "0  139.7      2.82    5.8  177.146  0.00     0.00  \n",
       "1  141.7      3.08    5.1  177.830  2.34     0.74  \n",
       "2  140.5      3.82    5.3  178.657  2.74     1.09  \n",
       "3  140.0      4.33    5.6  179.386  0.27     4.06  \n",
       "4  139.6      3.50    5.2  180.007  2.31     1.19  "
      ]
     },
     "execution_count": 220,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [200]: data = pd.read_csv('examples/macrodata.csv')\n",
    "In [201]: data.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      1959.0\n",
       "1      1959.0\n",
       "2      1959.0\n",
       "3      1959.0\n",
       "4      1960.0\n",
       "5      1960.0\n",
       "6      1960.0\n",
       "7      1960.0\n",
       "8      1961.0\n",
       "9      1961.0\n",
       "10     1961.0\n",
       "11     1961.0\n",
       "12     1962.0\n",
       "13     1962.0\n",
       "14     1962.0\n",
       "15     1962.0\n",
       "16     1963.0\n",
       "17     1963.0\n",
       "18     1963.0\n",
       "19     1963.0\n",
       "20     1964.0\n",
       "21     1964.0\n",
       "22     1964.0\n",
       "23     1964.0\n",
       "24     1965.0\n",
       "25     1965.0\n",
       "26     1965.0\n",
       "27     1965.0\n",
       "28     1966.0\n",
       "29     1966.0\n",
       "        ...  \n",
       "173    2002.0\n",
       "174    2002.0\n",
       "175    2002.0\n",
       "176    2003.0\n",
       "177    2003.0\n",
       "178    2003.0\n",
       "179    2003.0\n",
       "180    2004.0\n",
       "181    2004.0\n",
       "182    2004.0\n",
       "183    2004.0\n",
       "184    2005.0\n",
       "185    2005.0\n",
       "186    2005.0\n",
       "187    2005.0\n",
       "188    2006.0\n",
       "189    2006.0\n",
       "190    2006.0\n",
       "191    2006.0\n",
       "192    2007.0\n",
       "193    2007.0\n",
       "194    2007.0\n",
       "195    2007.0\n",
       "196    2008.0\n",
       "197    2008.0\n",
       "198    2008.0\n",
       "199    2008.0\n",
       "200    2009.0\n",
       "201    2009.0\n",
       "202    2009.0\n",
       "Name: year, Length: 203, dtype: float64"
      ]
     },
     "execution_count": 221,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      1.0\n",
       "1      2.0\n",
       "2      3.0\n",
       "3      4.0\n",
       "4      1.0\n",
       "5      2.0\n",
       "6      3.0\n",
       "7      4.0\n",
       "8      1.0\n",
       "9      2.0\n",
       "10     3.0\n",
       "11     4.0\n",
       "12     1.0\n",
       "13     2.0\n",
       "14     3.0\n",
       "15     4.0\n",
       "16     1.0\n",
       "17     2.0\n",
       "18     3.0\n",
       "19     4.0\n",
       "20     1.0\n",
       "21     2.0\n",
       "22     3.0\n",
       "23     4.0\n",
       "24     1.0\n",
       "25     2.0\n",
       "26     3.0\n",
       "27     4.0\n",
       "28     1.0\n",
       "29     2.0\n",
       "      ... \n",
       "173    2.0\n",
       "174    3.0\n",
       "175    4.0\n",
       "176    1.0\n",
       "177    2.0\n",
       "178    3.0\n",
       "179    4.0\n",
       "180    1.0\n",
       "181    2.0\n",
       "182    3.0\n",
       "183    4.0\n",
       "184    1.0\n",
       "185    2.0\n",
       "186    3.0\n",
       "187    4.0\n",
       "188    1.0\n",
       "189    2.0\n",
       "190    3.0\n",
       "191    4.0\n",
       "192    1.0\n",
       "193    2.0\n",
       "194    3.0\n",
       "195    4.0\n",
       "196    1.0\n",
       "197    2.0\n",
       "198    3.0\n",
       "199    4.0\n",
       "200    1.0\n",
       "201    2.0\n",
       "202    3.0\n",
       "Name: quarter, Length: 203, dtype: float64"
      ]
     },
     "execution_count": 222,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.quarter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 225,
   "metadata": {},
   "outputs": [],
   "source": [
    "index = pd.PeriodIndex(year=data.year,quarter=data.quarter,freq='Q-DEC')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 226,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['1959Q1', '1959Q2', '1959Q3', '1959Q4', '1960Q1', '1960Q2',\n",
       "             '1960Q3', '1960Q4', '1961Q1', '1961Q2',\n",
       "             ...\n",
       "             '2007Q2', '2007Q3', '2007Q4', '2008Q1', '2008Q2', '2008Q3',\n",
       "             '2008Q4', '2009Q1', '2009Q2', '2009Q3'],\n",
       "            dtype='period[Q-DEC]', length=203, freq='Q-DEC')"
      ]
     },
     "execution_count": 226,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.index = index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>quarter</th>\n",
       "      <th>realgdp</th>\n",
       "      <th>realcons</th>\n",
       "      <th>realinv</th>\n",
       "      <th>realgovt</th>\n",
       "      <th>realdpi</th>\n",
       "      <th>cpi</th>\n",
       "      <th>m1</th>\n",
       "      <th>tbilrate</th>\n",
       "      <th>unemp</th>\n",
       "      <th>pop</th>\n",
       "      <th>infl</th>\n",
       "      <th>realint</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1959Q1</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2710.349</td>\n",
       "      <td>1707.4</td>\n",
       "      <td>286.898</td>\n",
       "      <td>470.045</td>\n",
       "      <td>1886.9</td>\n",
       "      <td>28.980</td>\n",
       "      <td>139.7</td>\n",
       "      <td>2.82</td>\n",
       "      <td>5.8</td>\n",
       "      <td>177.146</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1959Q2</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2778.801</td>\n",
       "      <td>1733.7</td>\n",
       "      <td>310.859</td>\n",
       "      <td>481.301</td>\n",
       "      <td>1919.7</td>\n",
       "      <td>29.150</td>\n",
       "      <td>141.7</td>\n",
       "      <td>3.08</td>\n",
       "      <td>5.1</td>\n",
       "      <td>177.830</td>\n",
       "      <td>2.34</td>\n",
       "      <td>0.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1959Q3</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2775.488</td>\n",
       "      <td>1751.8</td>\n",
       "      <td>289.226</td>\n",
       "      <td>491.260</td>\n",
       "      <td>1916.4</td>\n",
       "      <td>29.350</td>\n",
       "      <td>140.5</td>\n",
       "      <td>3.82</td>\n",
       "      <td>5.3</td>\n",
       "      <td>178.657</td>\n",
       "      <td>2.74</td>\n",
       "      <td>1.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1959Q4</th>\n",
       "      <td>1959.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2785.204</td>\n",
       "      <td>1753.7</td>\n",
       "      <td>299.356</td>\n",
       "      <td>484.052</td>\n",
       "      <td>1931.3</td>\n",
       "      <td>29.370</td>\n",
       "      <td>140.0</td>\n",
       "      <td>4.33</td>\n",
       "      <td>5.6</td>\n",
       "      <td>179.386</td>\n",
       "      <td>0.27</td>\n",
       "      <td>4.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1960Q1</th>\n",
       "      <td>1960.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2847.699</td>\n",
       "      <td>1770.5</td>\n",
       "      <td>331.722</td>\n",
       "      <td>462.199</td>\n",
       "      <td>1955.5</td>\n",
       "      <td>29.540</td>\n",
       "      <td>139.6</td>\n",
       "      <td>3.50</td>\n",
       "      <td>5.2</td>\n",
       "      <td>180.007</td>\n",
       "      <td>2.31</td>\n",
       "      <td>1.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1960Q2</th>\n",
       "      <td>1960.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2834.390</td>\n",
       "      <td>1792.9</td>\n",
       "      <td>298.152</td>\n",
       "      <td>460.400</td>\n",
       "      <td>1966.1</td>\n",
       "      <td>29.550</td>\n",
       "      <td>140.2</td>\n",
       "      <td>2.68</td>\n",
       "      <td>5.2</td>\n",
       "      <td>180.671</td>\n",
       "      <td>0.14</td>\n",
       "      <td>2.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1960Q3</th>\n",
       "      <td>1960.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2839.022</td>\n",
       "      <td>1785.8</td>\n",
       "      <td>296.375</td>\n",
       "      <td>474.676</td>\n",
       "      <td>1967.8</td>\n",
       "      <td>29.750</td>\n",
       "      <td>140.9</td>\n",
       "      <td>2.36</td>\n",
       "      <td>5.6</td>\n",
       "      <td>181.528</td>\n",
       "      <td>2.70</td>\n",
       "      <td>-0.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1960Q4</th>\n",
       "      <td>1960.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2802.616</td>\n",
       "      <td>1788.2</td>\n",
       "      <td>259.764</td>\n",
       "      <td>476.434</td>\n",
       "      <td>1966.6</td>\n",
       "      <td>29.840</td>\n",
       "      <td>141.1</td>\n",
       "      <td>2.29</td>\n",
       "      <td>6.3</td>\n",
       "      <td>182.287</td>\n",
       "      <td>1.21</td>\n",
       "      <td>1.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1961Q1</th>\n",
       "      <td>1961.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2819.264</td>\n",
       "      <td>1787.7</td>\n",
       "      <td>266.405</td>\n",
       "      <td>475.854</td>\n",
       "      <td>1984.5</td>\n",
       "      <td>29.810</td>\n",
       "      <td>142.1</td>\n",
       "      <td>2.37</td>\n",
       "      <td>6.8</td>\n",
       "      <td>182.992</td>\n",
       "      <td>-0.40</td>\n",
       "      <td>2.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1961Q2</th>\n",
       "      <td>1961.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2872.005</td>\n",
       "      <td>1814.3</td>\n",
       "      <td>286.246</td>\n",
       "      <td>480.328</td>\n",
       "      <td>2014.4</td>\n",
       "      <td>29.920</td>\n",
       "      <td>142.9</td>\n",
       "      <td>2.29</td>\n",
       "      <td>7.0</td>\n",
       "      <td>183.691</td>\n",
       "      <td>1.47</td>\n",
       "      <td>0.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1961Q3</th>\n",
       "      <td>1961.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2918.419</td>\n",
       "      <td>1823.1</td>\n",
       "      <td>310.227</td>\n",
       "      <td>493.828</td>\n",
       "      <td>2041.9</td>\n",
       "      <td>29.980</td>\n",
       "      <td>144.1</td>\n",
       "      <td>2.32</td>\n",
       "      <td>6.8</td>\n",
       "      <td>184.524</td>\n",
       "      <td>0.80</td>\n",
       "      <td>1.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1961Q4</th>\n",
       "      <td>1961.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2977.830</td>\n",
       "      <td>1859.6</td>\n",
       "      <td>315.463</td>\n",
       "      <td>502.521</td>\n",
       "      <td>2082.0</td>\n",
       "      <td>30.040</td>\n",
       "      <td>145.2</td>\n",
       "      <td>2.60</td>\n",
       "      <td>6.2</td>\n",
       "      <td>185.242</td>\n",
       "      <td>0.80</td>\n",
       "      <td>1.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1962Q1</th>\n",
       "      <td>1962.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3031.241</td>\n",
       "      <td>1879.4</td>\n",
       "      <td>334.271</td>\n",
       "      <td>520.960</td>\n",
       "      <td>2101.7</td>\n",
       "      <td>30.210</td>\n",
       "      <td>146.4</td>\n",
       "      <td>2.73</td>\n",
       "      <td>5.6</td>\n",
       "      <td>185.874</td>\n",
       "      <td>2.26</td>\n",
       "      <td>0.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1962Q2</th>\n",
       "      <td>1962.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3064.709</td>\n",
       "      <td>1902.5</td>\n",
       "      <td>331.039</td>\n",
       "      <td>523.066</td>\n",
       "      <td>2125.2</td>\n",
       "      <td>30.220</td>\n",
       "      <td>146.5</td>\n",
       "      <td>2.78</td>\n",
       "      <td>5.5</td>\n",
       "      <td>186.538</td>\n",
       "      <td>0.13</td>\n",
       "      <td>2.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1962Q3</th>\n",
       "      <td>1962.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3093.047</td>\n",
       "      <td>1917.9</td>\n",
       "      <td>336.962</td>\n",
       "      <td>538.838</td>\n",
       "      <td>2137.0</td>\n",
       "      <td>30.380</td>\n",
       "      <td>146.7</td>\n",
       "      <td>2.78</td>\n",
       "      <td>5.6</td>\n",
       "      <td>187.323</td>\n",
       "      <td>2.11</td>\n",
       "      <td>0.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1962Q4</th>\n",
       "      <td>1962.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3100.563</td>\n",
       "      <td>1945.1</td>\n",
       "      <td>325.650</td>\n",
       "      <td>535.912</td>\n",
       "      <td>2154.6</td>\n",
       "      <td>30.440</td>\n",
       "      <td>148.3</td>\n",
       "      <td>2.87</td>\n",
       "      <td>5.5</td>\n",
       "      <td>188.013</td>\n",
       "      <td>0.79</td>\n",
       "      <td>2.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1963Q1</th>\n",
       "      <td>1963.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3141.087</td>\n",
       "      <td>1958.2</td>\n",
       "      <td>343.721</td>\n",
       "      <td>522.917</td>\n",
       "      <td>2172.5</td>\n",
       "      <td>30.480</td>\n",
       "      <td>149.7</td>\n",
       "      <td>2.90</td>\n",
       "      <td>5.8</td>\n",
       "      <td>188.580</td>\n",
       "      <td>0.53</td>\n",
       "      <td>2.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1963Q2</th>\n",
       "      <td>1963.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3180.447</td>\n",
       "      <td>1976.9</td>\n",
       "      <td>348.730</td>\n",
       "      <td>518.108</td>\n",
       "      <td>2193.1</td>\n",
       "      <td>30.690</td>\n",
       "      <td>151.3</td>\n",
       "      <td>3.03</td>\n",
       "      <td>5.7</td>\n",
       "      <td>189.242</td>\n",
       "      <td>2.75</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1963Q3</th>\n",
       "      <td>1963.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3240.332</td>\n",
       "      <td>2003.8</td>\n",
       "      <td>360.102</td>\n",
       "      <td>546.893</td>\n",
       "      <td>2217.9</td>\n",
       "      <td>30.750</td>\n",
       "      <td>152.6</td>\n",
       "      <td>3.38</td>\n",
       "      <td>5.5</td>\n",
       "      <td>190.028</td>\n",
       "      <td>0.78</td>\n",
       "      <td>2.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1963Q4</th>\n",
       "      <td>1963.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3264.967</td>\n",
       "      <td>2020.6</td>\n",
       "      <td>364.534</td>\n",
       "      <td>532.383</td>\n",
       "      <td>2254.6</td>\n",
       "      <td>30.940</td>\n",
       "      <td>153.7</td>\n",
       "      <td>3.52</td>\n",
       "      <td>5.6</td>\n",
       "      <td>190.668</td>\n",
       "      <td>2.46</td>\n",
       "      <td>1.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1964Q1</th>\n",
       "      <td>1964.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3338.246</td>\n",
       "      <td>2060.5</td>\n",
       "      <td>379.523</td>\n",
       "      <td>529.686</td>\n",
       "      <td>2299.6</td>\n",
       "      <td>30.950</td>\n",
       "      <td>154.8</td>\n",
       "      <td>3.51</td>\n",
       "      <td>5.5</td>\n",
       "      <td>191.245</td>\n",
       "      <td>0.13</td>\n",
       "      <td>3.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1964Q2</th>\n",
       "      <td>1964.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3376.587</td>\n",
       "      <td>2096.7</td>\n",
       "      <td>377.778</td>\n",
       "      <td>526.175</td>\n",
       "      <td>2362.1</td>\n",
       "      <td>31.020</td>\n",
       "      <td>156.8</td>\n",
       "      <td>3.47</td>\n",
       "      <td>5.2</td>\n",
       "      <td>191.889</td>\n",
       "      <td>0.90</td>\n",
       "      <td>2.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1964Q3</th>\n",
       "      <td>1964.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3422.469</td>\n",
       "      <td>2135.2</td>\n",
       "      <td>386.754</td>\n",
       "      <td>522.008</td>\n",
       "      <td>2392.7</td>\n",
       "      <td>31.120</td>\n",
       "      <td>159.2</td>\n",
       "      <td>3.53</td>\n",
       "      <td>5.0</td>\n",
       "      <td>192.631</td>\n",
       "      <td>1.29</td>\n",
       "      <td>2.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1964Q4</th>\n",
       "      <td>1964.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3431.957</td>\n",
       "      <td>2141.2</td>\n",
       "      <td>389.910</td>\n",
       "      <td>514.603</td>\n",
       "      <td>2420.4</td>\n",
       "      <td>31.280</td>\n",
       "      <td>160.7</td>\n",
       "      <td>3.76</td>\n",
       "      <td>5.0</td>\n",
       "      <td>193.223</td>\n",
       "      <td>2.05</td>\n",
       "      <td>1.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1965Q1</th>\n",
       "      <td>1965.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3516.251</td>\n",
       "      <td>2188.8</td>\n",
       "      <td>429.145</td>\n",
       "      <td>508.006</td>\n",
       "      <td>2447.4</td>\n",
       "      <td>31.380</td>\n",
       "      <td>162.0</td>\n",
       "      <td>3.93</td>\n",
       "      <td>4.9</td>\n",
       "      <td>193.709</td>\n",
       "      <td>1.28</td>\n",
       "      <td>2.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1965Q2</th>\n",
       "      <td>1965.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3563.960</td>\n",
       "      <td>2213.0</td>\n",
       "      <td>429.119</td>\n",
       "      <td>508.931</td>\n",
       "      <td>2474.5</td>\n",
       "      <td>31.580</td>\n",
       "      <td>163.1</td>\n",
       "      <td>3.84</td>\n",
       "      <td>4.7</td>\n",
       "      <td>194.303</td>\n",
       "      <td>2.54</td>\n",
       "      <td>1.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1965Q3</th>\n",
       "      <td>1965.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3636.285</td>\n",
       "      <td>2251.0</td>\n",
       "      <td>444.444</td>\n",
       "      <td>529.446</td>\n",
       "      <td>2542.6</td>\n",
       "      <td>31.650</td>\n",
       "      <td>166.0</td>\n",
       "      <td>3.93</td>\n",
       "      <td>4.4</td>\n",
       "      <td>194.997</td>\n",
       "      <td>0.89</td>\n",
       "      <td>3.04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1965Q4</th>\n",
       "      <td>1965.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3724.014</td>\n",
       "      <td>2314.3</td>\n",
       "      <td>446.493</td>\n",
       "      <td>544.121</td>\n",
       "      <td>2594.1</td>\n",
       "      <td>31.880</td>\n",
       "      <td>169.1</td>\n",
       "      <td>4.35</td>\n",
       "      <td>4.1</td>\n",
       "      <td>195.539</td>\n",
       "      <td>2.90</td>\n",
       "      <td>1.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1966Q1</th>\n",
       "      <td>1966.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3815.423</td>\n",
       "      <td>2348.5</td>\n",
       "      <td>484.244</td>\n",
       "      <td>556.593</td>\n",
       "      <td>2618.4</td>\n",
       "      <td>32.280</td>\n",
       "      <td>171.8</td>\n",
       "      <td>4.62</td>\n",
       "      <td>3.9</td>\n",
       "      <td>195.999</td>\n",
       "      <td>4.99</td>\n",
       "      <td>-0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1966Q2</th>\n",
       "      <td>1966.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3828.124</td>\n",
       "      <td>2354.5</td>\n",
       "      <td>475.408</td>\n",
       "      <td>571.371</td>\n",
       "      <td>2624.7</td>\n",
       "      <td>32.450</td>\n",
       "      <td>170.3</td>\n",
       "      <td>4.65</td>\n",
       "      <td>3.8</td>\n",
       "      <td>196.560</td>\n",
       "      <td>2.10</td>\n",
       "      <td>2.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002Q2</th>\n",
       "      <td>2002.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11538.770</td>\n",
       "      <td>7997.8</td>\n",
       "      <td>1810.779</td>\n",
       "      <td>774.408</td>\n",
       "      <td>8658.9</td>\n",
       "      <td>180.000</td>\n",
       "      <td>1199.5</td>\n",
       "      <td>1.70</td>\n",
       "      <td>5.8</td>\n",
       "      <td>288.028</td>\n",
       "      <td>1.56</td>\n",
       "      <td>0.14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002Q3</th>\n",
       "      <td>2002.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>11596.430</td>\n",
       "      <td>8052.0</td>\n",
       "      <td>1814.531</td>\n",
       "      <td>786.673</td>\n",
       "      <td>8629.2</td>\n",
       "      <td>181.200</td>\n",
       "      <td>1204.0</td>\n",
       "      <td>1.61</td>\n",
       "      <td>5.7</td>\n",
       "      <td>288.783</td>\n",
       "      <td>2.66</td>\n",
       "      <td>-1.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002Q4</th>\n",
       "      <td>2002.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>11598.824</td>\n",
       "      <td>8080.6</td>\n",
       "      <td>1813.219</td>\n",
       "      <td>799.967</td>\n",
       "      <td>8649.6</td>\n",
       "      <td>182.600</td>\n",
       "      <td>1226.8</td>\n",
       "      <td>1.20</td>\n",
       "      <td>5.8</td>\n",
       "      <td>289.421</td>\n",
       "      <td>3.08</td>\n",
       "      <td>-1.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003Q1</th>\n",
       "      <td>2003.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11645.819</td>\n",
       "      <td>8122.3</td>\n",
       "      <td>1813.141</td>\n",
       "      <td>800.196</td>\n",
       "      <td>8681.3</td>\n",
       "      <td>183.200</td>\n",
       "      <td>1248.4</td>\n",
       "      <td>1.14</td>\n",
       "      <td>5.9</td>\n",
       "      <td>290.019</td>\n",
       "      <td>1.31</td>\n",
       "      <td>-0.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003Q2</th>\n",
       "      <td>2003.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11738.706</td>\n",
       "      <td>8197.8</td>\n",
       "      <td>1823.698</td>\n",
       "      <td>838.775</td>\n",
       "      <td>8812.5</td>\n",
       "      <td>183.700</td>\n",
       "      <td>1287.9</td>\n",
       "      <td>0.96</td>\n",
       "      <td>6.2</td>\n",
       "      <td>290.704</td>\n",
       "      <td>1.09</td>\n",
       "      <td>-0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003Q3</th>\n",
       "      <td>2003.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>11935.461</td>\n",
       "      <td>8312.1</td>\n",
       "      <td>1889.883</td>\n",
       "      <td>839.598</td>\n",
       "      <td>8935.4</td>\n",
       "      <td>184.900</td>\n",
       "      <td>1297.3</td>\n",
       "      <td>0.94</td>\n",
       "      <td>6.1</td>\n",
       "      <td>291.449</td>\n",
       "      <td>2.60</td>\n",
       "      <td>-1.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003Q4</th>\n",
       "      <td>2003.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>12042.817</td>\n",
       "      <td>8358.0</td>\n",
       "      <td>1959.783</td>\n",
       "      <td>845.722</td>\n",
       "      <td>8986.4</td>\n",
       "      <td>186.300</td>\n",
       "      <td>1306.1</td>\n",
       "      <td>0.90</td>\n",
       "      <td>5.8</td>\n",
       "      <td>292.057</td>\n",
       "      <td>3.02</td>\n",
       "      <td>-2.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004Q1</th>\n",
       "      <td>2004.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12127.623</td>\n",
       "      <td>8437.6</td>\n",
       "      <td>1970.015</td>\n",
       "      <td>856.570</td>\n",
       "      <td>9025.9</td>\n",
       "      <td>187.400</td>\n",
       "      <td>1332.1</td>\n",
       "      <td>0.94</td>\n",
       "      <td>5.7</td>\n",
       "      <td>292.635</td>\n",
       "      <td>2.35</td>\n",
       "      <td>-1.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004Q2</th>\n",
       "      <td>2004.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>12213.818</td>\n",
       "      <td>8483.2</td>\n",
       "      <td>2055.580</td>\n",
       "      <td>861.440</td>\n",
       "      <td>9115.0</td>\n",
       "      <td>189.100</td>\n",
       "      <td>1340.5</td>\n",
       "      <td>1.21</td>\n",
       "      <td>5.6</td>\n",
       "      <td>293.310</td>\n",
       "      <td>3.61</td>\n",
       "      <td>-2.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004Q3</th>\n",
       "      <td>2004.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12303.533</td>\n",
       "      <td>8555.8</td>\n",
       "      <td>2082.231</td>\n",
       "      <td>876.385</td>\n",
       "      <td>9175.9</td>\n",
       "      <td>190.800</td>\n",
       "      <td>1361.0</td>\n",
       "      <td>1.63</td>\n",
       "      <td>5.4</td>\n",
       "      <td>294.066</td>\n",
       "      <td>3.58</td>\n",
       "      <td>-1.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004Q4</th>\n",
       "      <td>2004.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>12410.282</td>\n",
       "      <td>8654.2</td>\n",
       "      <td>2125.152</td>\n",
       "      <td>865.596</td>\n",
       "      <td>9303.4</td>\n",
       "      <td>191.800</td>\n",
       "      <td>1366.6</td>\n",
       "      <td>2.20</td>\n",
       "      <td>5.4</td>\n",
       "      <td>294.741</td>\n",
       "      <td>2.09</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005Q1</th>\n",
       "      <td>2005.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12534.113</td>\n",
       "      <td>8719.0</td>\n",
       "      <td>2170.299</td>\n",
       "      <td>869.204</td>\n",
       "      <td>9189.6</td>\n",
       "      <td>193.800</td>\n",
       "      <td>1357.8</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.3</td>\n",
       "      <td>295.308</td>\n",
       "      <td>4.15</td>\n",
       "      <td>-1.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005Q2</th>\n",
       "      <td>2005.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>12587.535</td>\n",
       "      <td>8802.9</td>\n",
       "      <td>2131.468</td>\n",
       "      <td>870.044</td>\n",
       "      <td>9253.0</td>\n",
       "      <td>194.700</td>\n",
       "      <td>1366.6</td>\n",
       "      <td>3.01</td>\n",
       "      <td>5.1</td>\n",
       "      <td>295.994</td>\n",
       "      <td>1.85</td>\n",
       "      <td>1.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005Q3</th>\n",
       "      <td>2005.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12683.153</td>\n",
       "      <td>8865.6</td>\n",
       "      <td>2154.949</td>\n",
       "      <td>890.394</td>\n",
       "      <td>9308.0</td>\n",
       "      <td>199.200</td>\n",
       "      <td>1375.0</td>\n",
       "      <td>3.52</td>\n",
       "      <td>5.0</td>\n",
       "      <td>296.770</td>\n",
       "      <td>9.14</td>\n",
       "      <td>-5.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005Q4</th>\n",
       "      <td>2005.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>12748.699</td>\n",
       "      <td>8888.5</td>\n",
       "      <td>2232.193</td>\n",
       "      <td>875.557</td>\n",
       "      <td>9358.7</td>\n",
       "      <td>199.400</td>\n",
       "      <td>1380.6</td>\n",
       "      <td>4.00</td>\n",
       "      <td>4.9</td>\n",
       "      <td>297.435</td>\n",
       "      <td>0.40</td>\n",
       "      <td>3.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006Q1</th>\n",
       "      <td>2006.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12915.938</td>\n",
       "      <td>8986.6</td>\n",
       "      <td>2264.721</td>\n",
       "      <td>900.511</td>\n",
       "      <td>9533.8</td>\n",
       "      <td>200.700</td>\n",
       "      <td>1380.5</td>\n",
       "      <td>4.51</td>\n",
       "      <td>4.7</td>\n",
       "      <td>298.061</td>\n",
       "      <td>2.60</td>\n",
       "      <td>1.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006Q2</th>\n",
       "      <td>2006.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>12962.462</td>\n",
       "      <td>9035.0</td>\n",
       "      <td>2261.247</td>\n",
       "      <td>892.839</td>\n",
       "      <td>9617.3</td>\n",
       "      <td>202.700</td>\n",
       "      <td>1369.2</td>\n",
       "      <td>4.82</td>\n",
       "      <td>4.7</td>\n",
       "      <td>298.766</td>\n",
       "      <td>3.97</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006Q3</th>\n",
       "      <td>2006.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12965.916</td>\n",
       "      <td>9090.7</td>\n",
       "      <td>2229.636</td>\n",
       "      <td>892.002</td>\n",
       "      <td>9662.5</td>\n",
       "      <td>201.900</td>\n",
       "      <td>1369.4</td>\n",
       "      <td>4.90</td>\n",
       "      <td>4.7</td>\n",
       "      <td>299.593</td>\n",
       "      <td>-1.58</td>\n",
       "      <td>6.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006Q4</th>\n",
       "      <td>2006.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>13060.679</td>\n",
       "      <td>9181.6</td>\n",
       "      <td>2165.966</td>\n",
       "      <td>894.404</td>\n",
       "      <td>9788.8</td>\n",
       "      <td>203.574</td>\n",
       "      <td>1373.6</td>\n",
       "      <td>4.92</td>\n",
       "      <td>4.4</td>\n",
       "      <td>300.320</td>\n",
       "      <td>3.30</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007Q1</th>\n",
       "      <td>2007.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>13099.901</td>\n",
       "      <td>9265.1</td>\n",
       "      <td>2132.609</td>\n",
       "      <td>882.766</td>\n",
       "      <td>9830.2</td>\n",
       "      <td>205.920</td>\n",
       "      <td>1379.7</td>\n",
       "      <td>4.95</td>\n",
       "      <td>4.5</td>\n",
       "      <td>300.977</td>\n",
       "      <td>4.58</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007Q2</th>\n",
       "      <td>2007.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13203.977</td>\n",
       "      <td>9291.5</td>\n",
       "      <td>2162.214</td>\n",
       "      <td>898.713</td>\n",
       "      <td>9842.7</td>\n",
       "      <td>207.338</td>\n",
       "      <td>1370.0</td>\n",
       "      <td>4.72</td>\n",
       "      <td>4.5</td>\n",
       "      <td>301.714</td>\n",
       "      <td>2.75</td>\n",
       "      <td>1.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007Q3</th>\n",
       "      <td>2007.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>13321.109</td>\n",
       "      <td>9335.6</td>\n",
       "      <td>2166.491</td>\n",
       "      <td>918.983</td>\n",
       "      <td>9883.9</td>\n",
       "      <td>209.133</td>\n",
       "      <td>1379.2</td>\n",
       "      <td>4.00</td>\n",
       "      <td>4.7</td>\n",
       "      <td>302.509</td>\n",
       "      <td>3.45</td>\n",
       "      <td>0.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007Q4</th>\n",
       "      <td>2007.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>13391.249</td>\n",
       "      <td>9363.6</td>\n",
       "      <td>2123.426</td>\n",
       "      <td>925.110</td>\n",
       "      <td>9886.2</td>\n",
       "      <td>212.495</td>\n",
       "      <td>1377.4</td>\n",
       "      <td>3.01</td>\n",
       "      <td>4.8</td>\n",
       "      <td>303.204</td>\n",
       "      <td>6.38</td>\n",
       "      <td>-3.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008Q1</th>\n",
       "      <td>2008.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>13366.865</td>\n",
       "      <td>9349.6</td>\n",
       "      <td>2082.886</td>\n",
       "      <td>943.372</td>\n",
       "      <td>9826.8</td>\n",
       "      <td>213.997</td>\n",
       "      <td>1384.0</td>\n",
       "      <td>1.56</td>\n",
       "      <td>4.9</td>\n",
       "      <td>303.803</td>\n",
       "      <td>2.82</td>\n",
       "      <td>-1.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008Q2</th>\n",
       "      <td>2008.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13415.266</td>\n",
       "      <td>9351.0</td>\n",
       "      <td>2026.518</td>\n",
       "      <td>961.280</td>\n",
       "      <td>10059.0</td>\n",
       "      <td>218.610</td>\n",
       "      <td>1409.3</td>\n",
       "      <td>1.74</td>\n",
       "      <td>5.4</td>\n",
       "      <td>304.483</td>\n",
       "      <td>8.53</td>\n",
       "      <td>-6.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008Q3</th>\n",
       "      <td>2008.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>13324.600</td>\n",
       "      <td>9267.7</td>\n",
       "      <td>1990.693</td>\n",
       "      <td>991.551</td>\n",
       "      <td>9838.3</td>\n",
       "      <td>216.889</td>\n",
       "      <td>1474.7</td>\n",
       "      <td>1.17</td>\n",
       "      <td>6.0</td>\n",
       "      <td>305.270</td>\n",
       "      <td>-3.16</td>\n",
       "      <td>4.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008Q4</th>\n",
       "      <td>2008.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>13141.920</td>\n",
       "      <td>9195.3</td>\n",
       "      <td>1857.661</td>\n",
       "      <td>1007.273</td>\n",
       "      <td>9920.4</td>\n",
       "      <td>212.174</td>\n",
       "      <td>1576.5</td>\n",
       "      <td>0.12</td>\n",
       "      <td>6.9</td>\n",
       "      <td>305.952</td>\n",
       "      <td>-8.79</td>\n",
       "      <td>8.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009Q1</th>\n",
       "      <td>2009.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12925.410</td>\n",
       "      <td>9209.2</td>\n",
       "      <td>1558.494</td>\n",
       "      <td>996.287</td>\n",
       "      <td>9926.4</td>\n",
       "      <td>212.671</td>\n",
       "      <td>1592.8</td>\n",
       "      <td>0.22</td>\n",
       "      <td>8.1</td>\n",
       "      <td>306.547</td>\n",
       "      <td>0.94</td>\n",
       "      <td>-0.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009Q2</th>\n",
       "      <td>2009.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>12901.504</td>\n",
       "      <td>9189.0</td>\n",
       "      <td>1456.678</td>\n",
       "      <td>1023.528</td>\n",
       "      <td>10077.5</td>\n",
       "      <td>214.469</td>\n",
       "      <td>1653.6</td>\n",
       "      <td>0.18</td>\n",
       "      <td>9.2</td>\n",
       "      <td>307.226</td>\n",
       "      <td>3.37</td>\n",
       "      <td>-3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009Q3</th>\n",
       "      <td>2009.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12990.341</td>\n",
       "      <td>9256.0</td>\n",
       "      <td>1486.398</td>\n",
       "      <td>1044.088</td>\n",
       "      <td>10040.6</td>\n",
       "      <td>216.385</td>\n",
       "      <td>1673.9</td>\n",
       "      <td>0.12</td>\n",
       "      <td>9.6</td>\n",
       "      <td>308.013</td>\n",
       "      <td>3.56</td>\n",
       "      <td>-3.44</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>203 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          year  quarter    realgdp  realcons   realinv  realgovt  realdpi  \\\n",
       "1959Q1  1959.0      1.0   2710.349    1707.4   286.898   470.045   1886.9   \n",
       "1959Q2  1959.0      2.0   2778.801    1733.7   310.859   481.301   1919.7   \n",
       "1959Q3  1959.0      3.0   2775.488    1751.8   289.226   491.260   1916.4   \n",
       "1959Q4  1959.0      4.0   2785.204    1753.7   299.356   484.052   1931.3   \n",
       "1960Q1  1960.0      1.0   2847.699    1770.5   331.722   462.199   1955.5   \n",
       "1960Q2  1960.0      2.0   2834.390    1792.9   298.152   460.400   1966.1   \n",
       "1960Q3  1960.0      3.0   2839.022    1785.8   296.375   474.676   1967.8   \n",
       "1960Q4  1960.0      4.0   2802.616    1788.2   259.764   476.434   1966.6   \n",
       "1961Q1  1961.0      1.0   2819.264    1787.7   266.405   475.854   1984.5   \n",
       "1961Q2  1961.0      2.0   2872.005    1814.3   286.246   480.328   2014.4   \n",
       "1961Q3  1961.0      3.0   2918.419    1823.1   310.227   493.828   2041.9   \n",
       "1961Q4  1961.0      4.0   2977.830    1859.6   315.463   502.521   2082.0   \n",
       "1962Q1  1962.0      1.0   3031.241    1879.4   334.271   520.960   2101.7   \n",
       "1962Q2  1962.0      2.0   3064.709    1902.5   331.039   523.066   2125.2   \n",
       "1962Q3  1962.0      3.0   3093.047    1917.9   336.962   538.838   2137.0   \n",
       "1962Q4  1962.0      4.0   3100.563    1945.1   325.650   535.912   2154.6   \n",
       "1963Q1  1963.0      1.0   3141.087    1958.2   343.721   522.917   2172.5   \n",
       "1963Q2  1963.0      2.0   3180.447    1976.9   348.730   518.108   2193.1   \n",
       "1963Q3  1963.0      3.0   3240.332    2003.8   360.102   546.893   2217.9   \n",
       "1963Q4  1963.0      4.0   3264.967    2020.6   364.534   532.383   2254.6   \n",
       "1964Q1  1964.0      1.0   3338.246    2060.5   379.523   529.686   2299.6   \n",
       "1964Q2  1964.0      2.0   3376.587    2096.7   377.778   526.175   2362.1   \n",
       "1964Q3  1964.0      3.0   3422.469    2135.2   386.754   522.008   2392.7   \n",
       "1964Q4  1964.0      4.0   3431.957    2141.2   389.910   514.603   2420.4   \n",
       "1965Q1  1965.0      1.0   3516.251    2188.8   429.145   508.006   2447.4   \n",
       "1965Q2  1965.0      2.0   3563.960    2213.0   429.119   508.931   2474.5   \n",
       "1965Q3  1965.0      3.0   3636.285    2251.0   444.444   529.446   2542.6   \n",
       "1965Q4  1965.0      4.0   3724.014    2314.3   446.493   544.121   2594.1   \n",
       "1966Q1  1966.0      1.0   3815.423    2348.5   484.244   556.593   2618.4   \n",
       "1966Q2  1966.0      2.0   3828.124    2354.5   475.408   571.371   2624.7   \n",
       "...        ...      ...        ...       ...       ...       ...      ...   \n",
       "2002Q2  2002.0      2.0  11538.770    7997.8  1810.779   774.408   8658.9   \n",
       "2002Q3  2002.0      3.0  11596.430    8052.0  1814.531   786.673   8629.2   \n",
       "2002Q4  2002.0      4.0  11598.824    8080.6  1813.219   799.967   8649.6   \n",
       "2003Q1  2003.0      1.0  11645.819    8122.3  1813.141   800.196   8681.3   \n",
       "2003Q2  2003.0      2.0  11738.706    8197.8  1823.698   838.775   8812.5   \n",
       "2003Q3  2003.0      3.0  11935.461    8312.1  1889.883   839.598   8935.4   \n",
       "2003Q4  2003.0      4.0  12042.817    8358.0  1959.783   845.722   8986.4   \n",
       "2004Q1  2004.0      1.0  12127.623    8437.6  1970.015   856.570   9025.9   \n",
       "2004Q2  2004.0      2.0  12213.818    8483.2  2055.580   861.440   9115.0   \n",
       "2004Q3  2004.0      3.0  12303.533    8555.8  2082.231   876.385   9175.9   \n",
       "2004Q4  2004.0      4.0  12410.282    8654.2  2125.152   865.596   9303.4   \n",
       "2005Q1  2005.0      1.0  12534.113    8719.0  2170.299   869.204   9189.6   \n",
       "2005Q2  2005.0      2.0  12587.535    8802.9  2131.468   870.044   9253.0   \n",
       "2005Q3  2005.0      3.0  12683.153    8865.6  2154.949   890.394   9308.0   \n",
       "2005Q4  2005.0      4.0  12748.699    8888.5  2232.193   875.557   9358.7   \n",
       "2006Q1  2006.0      1.0  12915.938    8986.6  2264.721   900.511   9533.8   \n",
       "2006Q2  2006.0      2.0  12962.462    9035.0  2261.247   892.839   9617.3   \n",
       "2006Q3  2006.0      3.0  12965.916    9090.7  2229.636   892.002   9662.5   \n",
       "2006Q4  2006.0      4.0  13060.679    9181.6  2165.966   894.404   9788.8   \n",
       "2007Q1  2007.0      1.0  13099.901    9265.1  2132.609   882.766   9830.2   \n",
       "2007Q2  2007.0      2.0  13203.977    9291.5  2162.214   898.713   9842.7   \n",
       "2007Q3  2007.0      3.0  13321.109    9335.6  2166.491   918.983   9883.9   \n",
       "2007Q4  2007.0      4.0  13391.249    9363.6  2123.426   925.110   9886.2   \n",
       "2008Q1  2008.0      1.0  13366.865    9349.6  2082.886   943.372   9826.8   \n",
       "2008Q2  2008.0      2.0  13415.266    9351.0  2026.518   961.280  10059.0   \n",
       "2008Q3  2008.0      3.0  13324.600    9267.7  1990.693   991.551   9838.3   \n",
       "2008Q4  2008.0      4.0  13141.920    9195.3  1857.661  1007.273   9920.4   \n",
       "2009Q1  2009.0      1.0  12925.410    9209.2  1558.494   996.287   9926.4   \n",
       "2009Q2  2009.0      2.0  12901.504    9189.0  1456.678  1023.528  10077.5   \n",
       "2009Q3  2009.0      3.0  12990.341    9256.0  1486.398  1044.088  10040.6   \n",
       "\n",
       "            cpi      m1  tbilrate  unemp      pop  infl  realint  \n",
       "1959Q1   28.980   139.7      2.82    5.8  177.146  0.00     0.00  \n",
       "1959Q2   29.150   141.7      3.08    5.1  177.830  2.34     0.74  \n",
       "1959Q3   29.350   140.5      3.82    5.3  178.657  2.74     1.09  \n",
       "1959Q4   29.370   140.0      4.33    5.6  179.386  0.27     4.06  \n",
       "1960Q1   29.540   139.6      3.50    5.2  180.007  2.31     1.19  \n",
       "1960Q2   29.550   140.2      2.68    5.2  180.671  0.14     2.55  \n",
       "1960Q3   29.750   140.9      2.36    5.6  181.528  2.70    -0.34  \n",
       "1960Q4   29.840   141.1      2.29    6.3  182.287  1.21     1.08  \n",
       "1961Q1   29.810   142.1      2.37    6.8  182.992 -0.40     2.77  \n",
       "1961Q2   29.920   142.9      2.29    7.0  183.691  1.47     0.81  \n",
       "1961Q3   29.980   144.1      2.32    6.8  184.524  0.80     1.52  \n",
       "1961Q4   30.040   145.2      2.60    6.2  185.242  0.80     1.80  \n",
       "1962Q1   30.210   146.4      2.73    5.6  185.874  2.26     0.47  \n",
       "1962Q2   30.220   146.5      2.78    5.5  186.538  0.13     2.65  \n",
       "1962Q3   30.380   146.7      2.78    5.6  187.323  2.11     0.67  \n",
       "1962Q4   30.440   148.3      2.87    5.5  188.013  0.79     2.08  \n",
       "1963Q1   30.480   149.7      2.90    5.8  188.580  0.53     2.38  \n",
       "1963Q2   30.690   151.3      3.03    5.7  189.242  2.75     0.29  \n",
       "1963Q3   30.750   152.6      3.38    5.5  190.028  0.78     2.60  \n",
       "1963Q4   30.940   153.7      3.52    5.6  190.668  2.46     1.06  \n",
       "1964Q1   30.950   154.8      3.51    5.5  191.245  0.13     3.38  \n",
       "1964Q2   31.020   156.8      3.47    5.2  191.889  0.90     2.57  \n",
       "1964Q3   31.120   159.2      3.53    5.0  192.631  1.29     2.25  \n",
       "1964Q4   31.280   160.7      3.76    5.0  193.223  2.05     1.71  \n",
       "1965Q1   31.380   162.0      3.93    4.9  193.709  1.28     2.65  \n",
       "1965Q2   31.580   163.1      3.84    4.7  194.303  2.54     1.30  \n",
       "1965Q3   31.650   166.0      3.93    4.4  194.997  0.89     3.04  \n",
       "1965Q4   31.880   169.1      4.35    4.1  195.539  2.90     1.46  \n",
       "1966Q1   32.280   171.8      4.62    3.9  195.999  4.99    -0.37  \n",
       "1966Q2   32.450   170.3      4.65    3.8  196.560  2.10     2.55  \n",
       "...         ...     ...       ...    ...      ...   ...      ...  \n",
       "2002Q2  180.000  1199.5      1.70    5.8  288.028  1.56     0.14  \n",
       "2002Q3  181.200  1204.0      1.61    5.7  288.783  2.66    -1.05  \n",
       "2002Q4  182.600  1226.8      1.20    5.8  289.421  3.08    -1.88  \n",
       "2003Q1  183.200  1248.4      1.14    5.9  290.019  1.31    -0.17  \n",
       "2003Q2  183.700  1287.9      0.96    6.2  290.704  1.09    -0.13  \n",
       "2003Q3  184.900  1297.3      0.94    6.1  291.449  2.60    -1.67  \n",
       "2003Q4  186.300  1306.1      0.90    5.8  292.057  3.02    -2.11  \n",
       "2004Q1  187.400  1332.1      0.94    5.7  292.635  2.35    -1.42  \n",
       "2004Q2  189.100  1340.5      1.21    5.6  293.310  3.61    -2.41  \n",
       "2004Q3  190.800  1361.0      1.63    5.4  294.066  3.58    -1.95  \n",
       "2004Q4  191.800  1366.6      2.20    5.4  294.741  2.09     0.11  \n",
       "2005Q1  193.800  1357.8      2.69    5.3  295.308  4.15    -1.46  \n",
       "2005Q2  194.700  1366.6      3.01    5.1  295.994  1.85     1.16  \n",
       "2005Q3  199.200  1375.0      3.52    5.0  296.770  9.14    -5.62  \n",
       "2005Q4  199.400  1380.6      4.00    4.9  297.435  0.40     3.60  \n",
       "2006Q1  200.700  1380.5      4.51    4.7  298.061  2.60     1.91  \n",
       "2006Q2  202.700  1369.2      4.82    4.7  298.766  3.97     0.85  \n",
       "2006Q3  201.900  1369.4      4.90    4.7  299.593 -1.58     6.48  \n",
       "2006Q4  203.574  1373.6      4.92    4.4  300.320  3.30     1.62  \n",
       "2007Q1  205.920  1379.7      4.95    4.5  300.977  4.58     0.36  \n",
       "2007Q2  207.338  1370.0      4.72    4.5  301.714  2.75     1.97  \n",
       "2007Q3  209.133  1379.2      4.00    4.7  302.509  3.45     0.55  \n",
       "2007Q4  212.495  1377.4      3.01    4.8  303.204  6.38    -3.37  \n",
       "2008Q1  213.997  1384.0      1.56    4.9  303.803  2.82    -1.26  \n",
       "2008Q2  218.610  1409.3      1.74    5.4  304.483  8.53    -6.79  \n",
       "2008Q3  216.889  1474.7      1.17    6.0  305.270 -3.16     4.33  \n",
       "2008Q4  212.174  1576.5      0.12    6.9  305.952 -8.79     8.91  \n",
       "2009Q1  212.671  1592.8      0.22    8.1  306.547  0.94    -0.71  \n",
       "2009Q2  214.469  1653.6      0.18    9.2  307.226  3.37    -3.19  \n",
       "2009Q3  216.385  1673.9      0.12    9.6  308.013  3.56    -3.44  \n",
       "\n",
       "[203 rows x 14 columns]"
      ]
     },
     "execution_count": 228,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01   -0.768387\n",
       "2000-01-02   -0.941647\n",
       "2000-01-03    0.204424\n",
       "2000-01-04   -1.285197\n",
       "2000-01-05   -0.778199\n",
       "2000-01-06   -0.464794\n",
       "2000-01-07    0.968855\n",
       "2000-01-08   -1.038679\n",
       "2000-01-09   -1.725554\n",
       "2000-01-10   -2.163238\n",
       "2000-01-11   -0.346454\n",
       "2000-01-12   -0.519967\n",
       "2000-01-13   -1.220327\n",
       "2000-01-14   -1.316864\n",
       "2000-01-15   -0.605272\n",
       "2000-01-16    0.682911\n",
       "2000-01-17    0.582273\n",
       "2000-01-18   -0.398816\n",
       "2000-01-19   -0.046964\n",
       "2000-01-20   -1.582881\n",
       "2000-01-21    0.697146\n",
       "2000-01-22    1.051535\n",
       "2000-01-23   -1.465803\n",
       "2000-01-24    0.099321\n",
       "2000-01-25   -1.182577\n",
       "2000-01-26    0.292281\n",
       "2000-01-27   -0.785957\n",
       "2000-01-28    0.034781\n",
       "2000-01-29   -0.148138\n",
       "2000-01-30    0.558333\n",
       "                ...   \n",
       "2000-03-11   -0.732585\n",
       "2000-03-12   -0.386676\n",
       "2000-03-13   -1.120791\n",
       "2000-03-14   -0.250229\n",
       "2000-03-15   -0.545234\n",
       "2000-03-16   -0.542934\n",
       "2000-03-17   -0.004620\n",
       "2000-03-18   -0.974357\n",
       "2000-03-19   -0.829396\n",
       "2000-03-20   -0.372855\n",
       "2000-03-21   -0.378961\n",
       "2000-03-22    1.842215\n",
       "2000-03-23    0.200712\n",
       "2000-03-24   -1.098540\n",
       "2000-03-25    0.177765\n",
       "2000-03-26   -1.015640\n",
       "2000-03-27    0.829043\n",
       "2000-03-28    1.266473\n",
       "2000-03-29   -0.598164\n",
       "2000-03-30   -0.297499\n",
       "2000-03-31    0.156879\n",
       "2000-04-01    1.160558\n",
       "2000-04-02   -1.163761\n",
       "2000-04-03    0.167965\n",
       "2000-04-04   -0.127578\n",
       "2000-04-05   -0.765967\n",
       "2000-04-06   -0.516657\n",
       "2000-04-07    0.754130\n",
       "2000-04-08   -0.239035\n",
       "2000-04-09   -0.115379\n",
       "Freq: D, Length: 100, dtype: float64"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [208]: rng = pd.date_range('2000-01-01', periods=100, freq='D')\n",
    "In [209]: ts = pd.Series(np.random.randn(len(rng)), index=rng)\n",
    "In [210]: ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-31   -0.422492\n",
       "2000-02-29    0.388509\n",
       "2000-03-31   -0.096392\n",
       "2000-04-30   -0.093969\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 230,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.resample('M').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01 00:00:00     0\n",
       "2000-01-01 00:01:00     1\n",
       "2000-01-01 00:02:00     2\n",
       "2000-01-01 00:03:00     3\n",
       "2000-01-01 00:04:00     4\n",
       "2000-01-01 00:05:00     5\n",
       "2000-01-01 00:06:00     6\n",
       "2000-01-01 00:07:00     7\n",
       "2000-01-01 00:08:00     8\n",
       "2000-01-01 00:09:00     9\n",
       "2000-01-01 00:10:00    10\n",
       "2000-01-01 00:11:00    11\n",
       "Freq: T, dtype: int32"
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [213]: rng = pd.date_range('2000-01-01', periods=12, freq='T')\n",
    "In [214]: ts = pd.Series(np.arange(12), index=rng)\n",
    "In [215]: ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1999-12-31 23:55:00     0\n",
       "2000-01-01 00:00:00    15\n",
       "2000-01-01 00:05:00    40\n",
       "2000-01-01 00:10:00    11\n",
       "Freq: 5T, dtype: int32"
      ]
     },
     "execution_count": 232,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.resample('5min',closed='right').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2000-01-01 00:00:00     0\n",
       "2000-01-01 00:05:00    15\n",
       "2000-01-01 00:10:00    40\n",
       "2000-01-01 00:15:00    11\n",
       "Freq: 5T, dtype: int32"
      ]
     },
     "execution_count": 237,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.resample('5min',closed='right',label='right').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1999-12-31 23:59:59     0\n",
       "2000-01-01 00:04:59    15\n",
       "2000-01-01 00:09:59    40\n",
       "2000-01-01 00:14:59    11\n",
       "Freq: 5T, dtype: int32"
      ]
     },
     "execution_count": 239,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.resample('5min',closed='right',label='right',loffset='-1s').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 240,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-01 00:00:00</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-01 00:05:00</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-01 00:10:00</th>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     open  high  low  close\n",
       "2000-01-01 00:00:00     0     4    0      4\n",
       "2000-01-01 00:05:00     5     9    5      9\n",
       "2000-01-01 00:10:00    10    11   10     11"
      ]
     },
     "execution_count": 240,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [220]: ts.resample('5min').ohlc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 242,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [221]: frame = pd.DataFrame(np.random.randn(2, 4),\n",
    ".....: index=pd.date_range('1/1/2000',periods=2,\n",
    ".....: freq='W-WED'),\n",
    ".....: columns=['Colorado', 'Texas', 'NewYork', 'Ohio'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-12</th>\n",
       "      <td>0.692097</td>\n",
       "      <td>0.757979</td>\n",
       "      <td>-0.341202</td>\n",
       "      <td>-0.143091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas   NewYork      Ohio\n",
       "2000-01-05 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-12  0.692097  0.757979 -0.341202 -0.143091"
      ]
     },
     "execution_count": 243,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_daily = frame.resample('D').asfreq()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-06</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-07</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-08</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-09</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-10</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-11</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-12</th>\n",
       "      <td>0.692097</td>\n",
       "      <td>0.757979</td>\n",
       "      <td>-0.341202</td>\n",
       "      <td>-0.143091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas   NewYork      Ohio\n",
       "2000-01-05 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-06       NaN       NaN       NaN       NaN\n",
       "2000-01-07       NaN       NaN       NaN       NaN\n",
       "2000-01-08       NaN       NaN       NaN       NaN\n",
       "2000-01-09       NaN       NaN       NaN       NaN\n",
       "2000-01-10       NaN       NaN       NaN       NaN\n",
       "2000-01-11       NaN       NaN       NaN       NaN\n",
       "2000-01-12  0.692097  0.757979 -0.341202 -0.143091"
      ]
     },
     "execution_count": 250,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_daily"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 252,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-06</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-07</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-08</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-09</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-10</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-11</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-12</th>\n",
       "      <td>0.692097</td>\n",
       "      <td>0.757979</td>\n",
       "      <td>-0.341202</td>\n",
       "      <td>-0.143091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas   NewYork      Ohio\n",
       "2000-01-05 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-06 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-07 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-08       NaN       NaN       NaN       NaN\n",
       "2000-01-09       NaN       NaN       NaN       NaN\n",
       "2000-01-10       NaN       NaN       NaN       NaN\n",
       "2000-01-11       NaN       NaN       NaN       NaN\n",
       "2000-01-12  0.692097  0.757979 -0.341202 -0.143091"
      ]
     },
     "execution_count": 252,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.resample(\"D\").ffill(limit=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-12</th>\n",
       "      <td>0.692097</td>\n",
       "      <td>0.757979</td>\n",
       "      <td>-0.341202</td>\n",
       "      <td>-0.143091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas   NewYork      Ohio\n",
       "2000-01-05 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-12  0.692097  0.757979 -0.341202 -0.143091"
      ]
     },
     "execution_count": 253,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-06</th>\n",
       "      <td>-0.775995</td>\n",
       "      <td>-0.638244</td>\n",
       "      <td>-0.781454</td>\n",
       "      <td>0.401789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-13</th>\n",
       "      <td>0.692097</td>\n",
       "      <td>0.757979</td>\n",
       "      <td>-0.341202</td>\n",
       "      <td>-0.143091</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Colorado     Texas   NewYork      Ohio\n",
       "2000-01-06 -0.775995 -0.638244 -0.781454  0.401789\n",
       "2000-01-13  0.692097  0.757979 -0.341202 -0.143091"
      ]
     },
     "execution_count": 254,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame.resample('W-THU').ffill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01</th>\n",
       "      <td>-0.303538</td>\n",
       "      <td>0.923017</td>\n",
       "      <td>0.971653</td>\n",
       "      <td>2.550999</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02</th>\n",
       "      <td>-1.659654</td>\n",
       "      <td>0.378540</td>\n",
       "      <td>-0.568642</td>\n",
       "      <td>-1.244990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03</th>\n",
       "      <td>1.363365</td>\n",
       "      <td>1.037500</td>\n",
       "      <td>0.152709</td>\n",
       "      <td>-0.022599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04</th>\n",
       "      <td>1.081703</td>\n",
       "      <td>-0.432727</td>\n",
       "      <td>1.012752</td>\n",
       "      <td>0.114056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05</th>\n",
       "      <td>0.178714</td>\n",
       "      <td>-0.792548</td>\n",
       "      <td>1.136298</td>\n",
       "      <td>-0.106198</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Colorado     Texas   NewYork      Ohio\n",
       "2000-01 -0.303538  0.923017  0.971653  2.550999\n",
       "2000-02 -1.659654  0.378540 -0.568642 -1.244990\n",
       "2000-03  1.363365  1.037500  0.152709 -0.022599\n",
       "2000-04  1.081703 -0.432727  1.012752  0.114056\n",
       "2000-05  0.178714 -0.792548  1.136298 -0.106198"
      ]
     },
     "execution_count": 257,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "In [228]: frame = pd.DataFrame(np.random.randn(24, 4),\n",
    ".....: index=pd.period_range('1-2000', '12-2001',\n",
    ".....: freq='M'),\n",
    ".....: columns=['Colorado', 'Texas', 'NewYork', 'Ohio'])\n",
    "In [229]: frame[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "metadata": {},
   "outputs": [],
   "source": [
    "annual_frame = frame.resample('A-DEC').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 259,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Colorado     Texas   NewYork      Ohio\n",
       "2000  0.116329  0.146545  0.627952  0.703464\n",
       "2001  0.117846  0.548881  0.350793 -0.207717"
      ]
     },
     "execution_count": 259,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "annual_frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 260,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000Q1</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000Q2</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000Q3</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000Q4</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q1</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q2</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q3</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q4</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Colorado     Texas   NewYork      Ohio\n",
       "2000Q1  0.116329  0.146545  0.627952  0.703464\n",
       "2000Q2  0.116329  0.146545  0.627952  0.703464\n",
       "2000Q3  0.116329  0.146545  0.627952  0.703464\n",
       "2000Q4  0.116329  0.146545  0.627952  0.703464\n",
       "2001Q1  0.117846  0.548881  0.350793 -0.207717\n",
       "2001Q2  0.117846  0.548881  0.350793 -0.207717\n",
       "2001Q3  0.117846  0.548881  0.350793 -0.207717\n",
       "2001Q4  0.117846  0.548881  0.350793 -0.207717"
      ]
     },
     "execution_count": 260,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "annual_frame.resample('Q-DEC').ffill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 261,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Colorado</th>\n",
       "      <th>Texas</th>\n",
       "      <th>NewYork</th>\n",
       "      <th>Ohio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000Q4</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q1</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q2</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q3</th>\n",
       "      <td>0.116329</td>\n",
       "      <td>0.146545</td>\n",
       "      <td>0.627952</td>\n",
       "      <td>0.703464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001Q4</th>\n",
       "      <td>0.117846</td>\n",
       "      <td>0.548881</td>\n",
       "      <td>0.350793</td>\n",
       "      <td>-0.207717</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Colorado     Texas   NewYork      Ohio\n",
       "2000Q4  0.116329  0.146545  0.627952  0.703464\n",
       "2001Q1  0.116329  0.146545  0.627952  0.703464\n",
       "2001Q2  0.116329  0.146545  0.627952  0.703464\n",
       "2001Q3  0.116329  0.146545  0.627952  0.703464\n",
       "2001Q4  0.117846  0.548881  0.350793 -0.207717"
      ]
     },
     "execution_count": 261,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "annual_frame.resample('Q-DEC',convention='end').ffill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 262,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [235]: close_px_all = pd.read_csv('examples/stock_px_2.csv',\n",
    ".....: parse_dates=True, index_col=0)\n",
    "In [236]: close_px = close_px_all[['AAPL', 'MSFT', 'XOM']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [237]: close_px = close_px.resample('B').ffill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>MSFT</th>\n",
       "      <th>XOM</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2003-01-02</th>\n",
       "      <td>7.40</td>\n",
       "      <td>21.11</td>\n",
       "      <td>29.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-03</th>\n",
       "      <td>7.45</td>\n",
       "      <td>21.14</td>\n",
       "      <td>29.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-06</th>\n",
       "      <td>7.45</td>\n",
       "      <td>21.52</td>\n",
       "      <td>29.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-07</th>\n",
       "      <td>7.43</td>\n",
       "      <td>21.93</td>\n",
       "      <td>28.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-08</th>\n",
       "      <td>7.28</td>\n",
       "      <td>21.31</td>\n",
       "      <td>28.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-09</th>\n",
       "      <td>7.34</td>\n",
       "      <td>21.93</td>\n",
       "      <td>29.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-10</th>\n",
       "      <td>7.36</td>\n",
       "      <td>21.97</td>\n",
       "      <td>29.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-13</th>\n",
       "      <td>7.32</td>\n",
       "      <td>22.16</td>\n",
       "      <td>28.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-14</th>\n",
       "      <td>7.30</td>\n",
       "      <td>22.39</td>\n",
       "      <td>29.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-15</th>\n",
       "      <td>7.22</td>\n",
       "      <td>22.11</td>\n",
       "      <td>28.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-16</th>\n",
       "      <td>7.31</td>\n",
       "      <td>21.75</td>\n",
       "      <td>28.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-17</th>\n",
       "      <td>7.05</td>\n",
       "      <td>20.22</td>\n",
       "      <td>28.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-20</th>\n",
       "      <td>7.05</td>\n",
       "      <td>20.22</td>\n",
       "      <td>28.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-21</th>\n",
       "      <td>7.01</td>\n",
       "      <td>20.17</td>\n",
       "      <td>27.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-22</th>\n",
       "      <td>6.94</td>\n",
       "      <td>20.04</td>\n",
       "      <td>27.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-23</th>\n",
       "      <td>7.09</td>\n",
       "      <td>20.54</td>\n",
       "      <td>27.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-24</th>\n",
       "      <td>6.90</td>\n",
       "      <td>19.59</td>\n",
       "      <td>26.93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-27</th>\n",
       "      <td>7.07</td>\n",
       "      <td>19.32</td>\n",
       "      <td>26.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-28</th>\n",
       "      <td>7.29</td>\n",
       "      <td>19.18</td>\n",
       "      <td>26.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-29</th>\n",
       "      <td>7.47</td>\n",
       "      <td>19.61</td>\n",
       "      <td>27.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-30</th>\n",
       "      <td>7.16</td>\n",
       "      <td>18.95</td>\n",
       "      <td>27.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-31</th>\n",
       "      <td>7.18</td>\n",
       "      <td>18.65</td>\n",
       "      <td>28.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-03</th>\n",
       "      <td>7.33</td>\n",
       "      <td>19.08</td>\n",
       "      <td>28.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-04</th>\n",
       "      <td>7.30</td>\n",
       "      <td>18.59</td>\n",
       "      <td>28.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-05</th>\n",
       "      <td>7.22</td>\n",
       "      <td>18.45</td>\n",
       "      <td>28.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-06</th>\n",
       "      <td>7.22</td>\n",
       "      <td>18.63</td>\n",
       "      <td>27.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-07</th>\n",
       "      <td>7.07</td>\n",
       "      <td>18.30</td>\n",
       "      <td>27.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-10</th>\n",
       "      <td>7.18</td>\n",
       "      <td>18.62</td>\n",
       "      <td>27.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-11</th>\n",
       "      <td>7.18</td>\n",
       "      <td>18.25</td>\n",
       "      <td>27.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-12</th>\n",
       "      <td>7.20</td>\n",
       "      <td>18.25</td>\n",
       "      <td>27.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-05</th>\n",
       "      <td>374.05</td>\n",
       "      <td>25.80</td>\n",
       "      <td>72.14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-06</th>\n",
       "      <td>379.74</td>\n",
       "      <td>25.51</td>\n",
       "      <td>71.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-07</th>\n",
       "      <td>383.93</td>\n",
       "      <td>26.00</td>\n",
       "      <td>73.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-08</th>\n",
       "      <td>384.14</td>\n",
       "      <td>26.22</td>\n",
       "      <td>72.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-09</th>\n",
       "      <td>377.48</td>\n",
       "      <td>25.74</td>\n",
       "      <td>71.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-12</th>\n",
       "      <td>379.94</td>\n",
       "      <td>25.89</td>\n",
       "      <td>71.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-13</th>\n",
       "      <td>384.62</td>\n",
       "      <td>26.04</td>\n",
       "      <td>71.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-14</th>\n",
       "      <td>389.30</td>\n",
       "      <td>26.50</td>\n",
       "      <td>72.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-15</th>\n",
       "      <td>392.96</td>\n",
       "      <td>26.99</td>\n",
       "      <td>74.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-16</th>\n",
       "      <td>400.50</td>\n",
       "      <td>27.12</td>\n",
       "      <td>74.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-19</th>\n",
       "      <td>411.63</td>\n",
       "      <td>27.21</td>\n",
       "      <td>73.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-20</th>\n",
       "      <td>413.45</td>\n",
       "      <td>26.98</td>\n",
       "      <td>74.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-21</th>\n",
       "      <td>412.14</td>\n",
       "      <td>25.99</td>\n",
       "      <td>71.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-22</th>\n",
       "      <td>401.82</td>\n",
       "      <td>25.06</td>\n",
       "      <td>69.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-23</th>\n",
       "      <td>404.30</td>\n",
       "      <td>25.06</td>\n",
       "      <td>69.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-26</th>\n",
       "      <td>403.17</td>\n",
       "      <td>25.44</td>\n",
       "      <td>71.72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-27</th>\n",
       "      <td>399.26</td>\n",
       "      <td>25.67</td>\n",
       "      <td>72.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-28</th>\n",
       "      <td>397.01</td>\n",
       "      <td>25.58</td>\n",
       "      <td>72.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-29</th>\n",
       "      <td>390.57</td>\n",
       "      <td>25.45</td>\n",
       "      <td>73.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-30</th>\n",
       "      <td>381.32</td>\n",
       "      <td>24.89</td>\n",
       "      <td>72.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-03</th>\n",
       "      <td>374.60</td>\n",
       "      <td>24.53</td>\n",
       "      <td>71.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-04</th>\n",
       "      <td>372.50</td>\n",
       "      <td>25.34</td>\n",
       "      <td>72.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-05</th>\n",
       "      <td>378.25</td>\n",
       "      <td>25.89</td>\n",
       "      <td>73.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-06</th>\n",
       "      <td>377.37</td>\n",
       "      <td>26.34</td>\n",
       "      <td>73.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-07</th>\n",
       "      <td>369.80</td>\n",
       "      <td>26.25</td>\n",
       "      <td>73.56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-10</th>\n",
       "      <td>388.81</td>\n",
       "      <td>26.94</td>\n",
       "      <td>76.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-11</th>\n",
       "      <td>400.29</td>\n",
       "      <td>27.00</td>\n",
       "      <td>76.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-12</th>\n",
       "      <td>402.19</td>\n",
       "      <td>26.96</td>\n",
       "      <td>77.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-13</th>\n",
       "      <td>408.43</td>\n",
       "      <td>27.18</td>\n",
       "      <td>76.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-14</th>\n",
       "      <td>422.00</td>\n",
       "      <td>27.27</td>\n",
       "      <td>78.11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2292 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              AAPL   MSFT    XOM\n",
       "2003-01-02    7.40  21.11  29.22\n",
       "2003-01-03    7.45  21.14  29.24\n",
       "2003-01-06    7.45  21.52  29.96\n",
       "2003-01-07    7.43  21.93  28.95\n",
       "2003-01-08    7.28  21.31  28.83\n",
       "2003-01-09    7.34  21.93  29.44\n",
       "2003-01-10    7.36  21.97  29.03\n",
       "2003-01-13    7.32  22.16  28.91\n",
       "2003-01-14    7.30  22.39  29.17\n",
       "2003-01-15    7.22  22.11  28.77\n",
       "2003-01-16    7.31  21.75  28.90\n",
       "2003-01-17    7.05  20.22  28.60\n",
       "2003-01-20    7.05  20.22  28.60\n",
       "2003-01-21    7.01  20.17  27.94\n",
       "2003-01-22    6.94  20.04  27.58\n",
       "2003-01-23    7.09  20.54  27.52\n",
       "2003-01-24    6.90  19.59  26.93\n",
       "2003-01-27    7.07  19.32  26.21\n",
       "2003-01-28    7.29  19.18  26.90\n",
       "2003-01-29    7.47  19.61  27.88\n",
       "2003-01-30    7.16  18.95  27.37\n",
       "2003-01-31    7.18  18.65  28.13\n",
       "2003-02-03    7.33  19.08  28.52\n",
       "2003-02-04    7.30  18.59  28.52\n",
       "2003-02-05    7.22  18.45  28.11\n",
       "2003-02-06    7.22  18.63  27.87\n",
       "2003-02-07    7.07  18.30  27.66\n",
       "2003-02-10    7.18  18.62  27.87\n",
       "2003-02-11    7.18  18.25  27.67\n",
       "2003-02-12    7.20  18.25  27.12\n",
       "...            ...    ...    ...\n",
       "2011-09-05  374.05  25.80  72.14\n",
       "2011-09-06  379.74  25.51  71.15\n",
       "2011-09-07  383.93  26.00  73.65\n",
       "2011-09-08  384.14  26.22  72.82\n",
       "2011-09-09  377.48  25.74  71.01\n",
       "2011-09-12  379.94  25.89  71.84\n",
       "2011-09-13  384.62  26.04  71.65\n",
       "2011-09-14  389.30  26.50  72.64\n",
       "2011-09-15  392.96  26.99  74.01\n",
       "2011-09-16  400.50  27.12  74.55\n",
       "2011-09-19  411.63  27.21  73.70\n",
       "2011-09-20  413.45  26.98  74.01\n",
       "2011-09-21  412.14  25.99  71.97\n",
       "2011-09-22  401.82  25.06  69.24\n",
       "2011-09-23  404.30  25.06  69.31\n",
       "2011-09-26  403.17  25.44  71.72\n",
       "2011-09-27  399.26  25.67  72.91\n",
       "2011-09-28  397.01  25.58  72.07\n",
       "2011-09-29  390.57  25.45  73.88\n",
       "2011-09-30  381.32  24.89  72.63\n",
       "2011-10-03  374.60  24.53  71.15\n",
       "2011-10-04  372.50  25.34  72.83\n",
       "2011-10-05  378.25  25.89  73.95\n",
       "2011-10-06  377.37  26.34  73.89\n",
       "2011-10-07  369.80  26.25  73.56\n",
       "2011-10-10  388.81  26.94  76.28\n",
       "2011-10-11  400.29  27.00  76.27\n",
       "2011-10-12  402.19  26.96  77.16\n",
       "2011-10-13  408.43  27.18  76.37\n",
       "2011-10-14  422.00  27.27  78.11\n",
       "\n",
       "[2292 rows x 3 columns]"
      ]
     },
     "execution_count": 264,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 265,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e1664659b0>"
      ]
     },
     "execution_count": 265,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px.AAPL.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 272,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning: Cannot change to a different GUI toolkit: notebook. Using qt instead.\n"
     ]
    }
   ],
   "source": [
    "%matplotlib notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 273,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 273,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px.AAPL.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 280,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 280,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px.AAPL.rolling(90).mean().plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 275,
   "metadata": {},
   "outputs": [],
   "source": [
    "appl_std250 = close_px.AAPL.rolling(250,min_periods=10).std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 276,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2003-01-09         NaN\n",
       "2003-01-10         NaN\n",
       "2003-01-13         NaN\n",
       "2003-01-14         NaN\n",
       "2003-01-15    0.077496\n",
       "2003-01-16    0.074760\n",
       "2003-01-17    0.112368\n",
       "Freq: B, Name: AAPL, dtype: float64"
      ]
     },
     "execution_count": 276,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "appl_std250[5:12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 277,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 277,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "appl_std250.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 281,
   "metadata": {},
   "outputs": [],
   "source": [
    "ex_mean = appl_std250.expanding().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 282,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2292,)"
      ]
     },
     "execution_count": 282,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_mean.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 283,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2292,)"
      ]
     },
     "execution_count": 283,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "appl_std250.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 286,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2292, 3)"
      ]
     },
     "execution_count": 286,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 287,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 287,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_mean.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 288,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16ca48518>"
      ]
     },
     "execution_count": 288,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\matplotlib\\scale.py:111: RuntimeWarning: invalid value encountered in less_equal\n",
      "  out[a <= 0] = -1000\n"
     ]
    }
   ],
   "source": [
    "close_px.rolling(60).mean().plot(logy=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 289,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>MSFT</th>\n",
       "      <th>XOM</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2003-01-02</th>\n",
       "      <td>7.400000</td>\n",
       "      <td>21.110000</td>\n",
       "      <td>29.220000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-03</th>\n",
       "      <td>7.425000</td>\n",
       "      <td>21.125000</td>\n",
       "      <td>29.230000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-06</th>\n",
       "      <td>7.433333</td>\n",
       "      <td>21.256667</td>\n",
       "      <td>29.473333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-07</th>\n",
       "      <td>7.432500</td>\n",
       "      <td>21.425000</td>\n",
       "      <td>29.342500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-08</th>\n",
       "      <td>7.402000</td>\n",
       "      <td>21.402000</td>\n",
       "      <td>29.240000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-09</th>\n",
       "      <td>7.391667</td>\n",
       "      <td>21.490000</td>\n",
       "      <td>29.273333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-10</th>\n",
       "      <td>7.387143</td>\n",
       "      <td>21.558571</td>\n",
       "      <td>29.238571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-13</th>\n",
       "      <td>7.378750</td>\n",
       "      <td>21.633750</td>\n",
       "      <td>29.197500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-14</th>\n",
       "      <td>7.370000</td>\n",
       "      <td>21.717778</td>\n",
       "      <td>29.194444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-15</th>\n",
       "      <td>7.355000</td>\n",
       "      <td>21.757000</td>\n",
       "      <td>29.152000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-16</th>\n",
       "      <td>7.350909</td>\n",
       "      <td>21.756364</td>\n",
       "      <td>29.129091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-17</th>\n",
       "      <td>7.325833</td>\n",
       "      <td>21.628333</td>\n",
       "      <td>29.085000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-20</th>\n",
       "      <td>7.304615</td>\n",
       "      <td>21.520000</td>\n",
       "      <td>29.047692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-21</th>\n",
       "      <td>7.283571</td>\n",
       "      <td>21.423571</td>\n",
       "      <td>28.968571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-22</th>\n",
       "      <td>7.250714</td>\n",
       "      <td>21.347143</td>\n",
       "      <td>28.851429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-23</th>\n",
       "      <td>7.225000</td>\n",
       "      <td>21.304286</td>\n",
       "      <td>28.728571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-24</th>\n",
       "      <td>7.203333</td>\n",
       "      <td>21.190000</td>\n",
       "      <td>28.608667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-27</th>\n",
       "      <td>7.160000</td>\n",
       "      <td>20.980000</td>\n",
       "      <td>28.316429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-28</th>\n",
       "      <td>7.160714</td>\n",
       "      <td>20.827857</td>\n",
       "      <td>28.178571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-29</th>\n",
       "      <td>7.170000</td>\n",
       "      <td>20.662143</td>\n",
       "      <td>28.067143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-30</th>\n",
       "      <td>7.155714</td>\n",
       "      <td>20.446429</td>\n",
       "      <td>27.948571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-01-31</th>\n",
       "      <td>7.157333</td>\n",
       "      <td>20.326667</td>\n",
       "      <td>27.960667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-03</th>\n",
       "      <td>7.147857</td>\n",
       "      <td>19.959286</td>\n",
       "      <td>27.846429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-04</th>\n",
       "      <td>7.153571</td>\n",
       "      <td>19.707857</td>\n",
       "      <td>27.828571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-05</th>\n",
       "      <td>7.147143</td>\n",
       "      <td>19.472143</td>\n",
       "      <td>27.772143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-06</th>\n",
       "      <td>7.159286</td>\n",
       "      <td>19.358571</td>\n",
       "      <td>27.720000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-07</th>\n",
       "      <td>7.153333</td>\n",
       "      <td>19.288000</td>\n",
       "      <td>27.716000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-10</th>\n",
       "      <td>7.172857</td>\n",
       "      <td>19.110714</td>\n",
       "      <td>27.647857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-11</th>\n",
       "      <td>7.190000</td>\n",
       "      <td>18.982857</td>\n",
       "      <td>27.654286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003-02-12</th>\n",
       "      <td>7.197857</td>\n",
       "      <td>18.819286</td>\n",
       "      <td>27.625714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-05</th>\n",
       "      <td>375.711429</td>\n",
       "      <td>25.276429</td>\n",
       "      <td>72.607857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-06</th>\n",
       "      <td>375.661429</td>\n",
       "      <td>25.295000</td>\n",
       "      <td>72.392857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-07</th>\n",
       "      <td>376.938571</td>\n",
       "      <td>25.390000</td>\n",
       "      <td>72.586429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-08</th>\n",
       "      <td>378.946429</td>\n",
       "      <td>25.545000</td>\n",
       "      <td>72.802143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-09</th>\n",
       "      <td>378.848667</td>\n",
       "      <td>25.558000</td>\n",
       "      <td>72.682667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-12</th>\n",
       "      <td>380.902143</td>\n",
       "      <td>25.754286</td>\n",
       "      <td>72.731429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-13</th>\n",
       "      <td>381.505000</td>\n",
       "      <td>25.835714</td>\n",
       "      <td>72.596429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-14</th>\n",
       "      <td>382.617857</td>\n",
       "      <td>25.973571</td>\n",
       "      <td>72.658571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-15</th>\n",
       "      <td>383.287857</td>\n",
       "      <td>26.097857</td>\n",
       "      <td>72.756429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-16</th>\n",
       "      <td>384.435333</td>\n",
       "      <td>26.166000</td>\n",
       "      <td>72.876000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-19</th>\n",
       "      <td>385.585714</td>\n",
       "      <td>26.259286</td>\n",
       "      <td>72.772143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-20</th>\n",
       "      <td>387.630000</td>\n",
       "      <td>26.286429</td>\n",
       "      <td>72.771429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-21</th>\n",
       "      <td>389.852143</td>\n",
       "      <td>26.270714</td>\n",
       "      <td>72.662857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-22</th>\n",
       "      <td>391.835714</td>\n",
       "      <td>26.217857</td>\n",
       "      <td>72.455714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-23</th>\n",
       "      <td>392.666667</td>\n",
       "      <td>26.140667</td>\n",
       "      <td>72.246000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-26</th>\n",
       "      <td>395.670000</td>\n",
       "      <td>26.160000</td>\n",
       "      <td>72.294286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-27</th>\n",
       "      <td>396.765000</td>\n",
       "      <td>26.136429</td>\n",
       "      <td>72.241429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-28</th>\n",
       "      <td>397.684286</td>\n",
       "      <td>26.090714</td>\n",
       "      <td>72.187857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-29</th>\n",
       "      <td>398.619286</td>\n",
       "      <td>26.070000</td>\n",
       "      <td>72.392857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-09-30</th>\n",
       "      <td>397.466000</td>\n",
       "      <td>25.991333</td>\n",
       "      <td>72.408667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-03</th>\n",
       "      <td>398.002143</td>\n",
       "      <td>25.890714</td>\n",
       "      <td>72.413571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-04</th>\n",
       "      <td>396.802143</td>\n",
       "      <td>25.807857</td>\n",
       "      <td>72.427143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-05</th>\n",
       "      <td>395.751429</td>\n",
       "      <td>25.729286</td>\n",
       "      <td>72.422857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-06</th>\n",
       "      <td>394.099286</td>\n",
       "      <td>25.673571</td>\n",
       "      <td>72.375714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-07</th>\n",
       "      <td>392.479333</td>\n",
       "      <td>25.712000</td>\n",
       "      <td>72.454667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-10</th>\n",
       "      <td>389.351429</td>\n",
       "      <td>25.602143</td>\n",
       "      <td>72.527857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-11</th>\n",
       "      <td>388.505000</td>\n",
       "      <td>25.674286</td>\n",
       "      <td>72.835000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-12</th>\n",
       "      <td>388.531429</td>\n",
       "      <td>25.810000</td>\n",
       "      <td>73.400714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-13</th>\n",
       "      <td>388.826429</td>\n",
       "      <td>25.961429</td>\n",
       "      <td>73.905000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-10-14</th>\n",
       "      <td>391.038000</td>\n",
       "      <td>26.048667</td>\n",
       "      <td>74.185333</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2292 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  AAPL       MSFT        XOM\n",
       "2003-01-02    7.400000  21.110000  29.220000\n",
       "2003-01-03    7.425000  21.125000  29.230000\n",
       "2003-01-06    7.433333  21.256667  29.473333\n",
       "2003-01-07    7.432500  21.425000  29.342500\n",
       "2003-01-08    7.402000  21.402000  29.240000\n",
       "2003-01-09    7.391667  21.490000  29.273333\n",
       "2003-01-10    7.387143  21.558571  29.238571\n",
       "2003-01-13    7.378750  21.633750  29.197500\n",
       "2003-01-14    7.370000  21.717778  29.194444\n",
       "2003-01-15    7.355000  21.757000  29.152000\n",
       "2003-01-16    7.350909  21.756364  29.129091\n",
       "2003-01-17    7.325833  21.628333  29.085000\n",
       "2003-01-20    7.304615  21.520000  29.047692\n",
       "2003-01-21    7.283571  21.423571  28.968571\n",
       "2003-01-22    7.250714  21.347143  28.851429\n",
       "2003-01-23    7.225000  21.304286  28.728571\n",
       "2003-01-24    7.203333  21.190000  28.608667\n",
       "2003-01-27    7.160000  20.980000  28.316429\n",
       "2003-01-28    7.160714  20.827857  28.178571\n",
       "2003-01-29    7.170000  20.662143  28.067143\n",
       "2003-01-30    7.155714  20.446429  27.948571\n",
       "2003-01-31    7.157333  20.326667  27.960667\n",
       "2003-02-03    7.147857  19.959286  27.846429\n",
       "2003-02-04    7.153571  19.707857  27.828571\n",
       "2003-02-05    7.147143  19.472143  27.772143\n",
       "2003-02-06    7.159286  19.358571  27.720000\n",
       "2003-02-07    7.153333  19.288000  27.716000\n",
       "2003-02-10    7.172857  19.110714  27.647857\n",
       "2003-02-11    7.190000  18.982857  27.654286\n",
       "2003-02-12    7.197857  18.819286  27.625714\n",
       "...                ...        ...        ...\n",
       "2011-09-05  375.711429  25.276429  72.607857\n",
       "2011-09-06  375.661429  25.295000  72.392857\n",
       "2011-09-07  376.938571  25.390000  72.586429\n",
       "2011-09-08  378.946429  25.545000  72.802143\n",
       "2011-09-09  378.848667  25.558000  72.682667\n",
       "2011-09-12  380.902143  25.754286  72.731429\n",
       "2011-09-13  381.505000  25.835714  72.596429\n",
       "2011-09-14  382.617857  25.973571  72.658571\n",
       "2011-09-15  383.287857  26.097857  72.756429\n",
       "2011-09-16  384.435333  26.166000  72.876000\n",
       "2011-09-19  385.585714  26.259286  72.772143\n",
       "2011-09-20  387.630000  26.286429  72.771429\n",
       "2011-09-21  389.852143  26.270714  72.662857\n",
       "2011-09-22  391.835714  26.217857  72.455714\n",
       "2011-09-23  392.666667  26.140667  72.246000\n",
       "2011-09-26  395.670000  26.160000  72.294286\n",
       "2011-09-27  396.765000  26.136429  72.241429\n",
       "2011-09-28  397.684286  26.090714  72.187857\n",
       "2011-09-29  398.619286  26.070000  72.392857\n",
       "2011-09-30  397.466000  25.991333  72.408667\n",
       "2011-10-03  398.002143  25.890714  72.413571\n",
       "2011-10-04  396.802143  25.807857  72.427143\n",
       "2011-10-05  395.751429  25.729286  72.422857\n",
       "2011-10-06  394.099286  25.673571  72.375714\n",
       "2011-10-07  392.479333  25.712000  72.454667\n",
       "2011-10-10  389.351429  25.602143  72.527857\n",
       "2011-10-11  388.505000  25.674286  72.835000\n",
       "2011-10-12  388.531429  25.810000  73.400714\n",
       "2011-10-13  388.826429  25.961429  73.905000\n",
       "2011-10-14  391.038000  26.048667  74.185333\n",
       "\n",
       "[2292 rows x 3 columns]"
      ]
     },
     "execution_count": 289,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "close_px.rolling('20D').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 290,
   "metadata": {},
   "outputs": [],
   "source": [
    "aapl_px = close_px.AAPL['2006':'2007']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 291,
   "metadata": {},
   "outputs": [],
   "source": [
    "ma60 = aapl_px.rolling(30,min_periods=20).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 292,
   "metadata": {},
   "outputs": [],
   "source": [
    "ewma60 = aapl_px.ewm(span=30).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 293,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 293,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ma60.plot(style='k--',label='Simple MA')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 294,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 294,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ewma60.plot(style='k-',label='EW MA')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 295,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 296,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1e16f32ae80>"
      ]
     },
     "execution_count": 296,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 297,
   "metadata": {},
   "outputs": [],
   "source": [
    "In [256]: spx_px = close_px_all['SPX']\n",
    "In [257]: spx_rets = spx_px.pct_change()\n",
    "In [258]: returns = close_px.pct_change()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 298,
   "metadata": {},
   "outputs": [],
   "source": [
    "corr = returns.AAPL.rolling(125,min_periods=100).corr(spx_rets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 299,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2003-01-02         NaN\n",
       "2003-01-03         NaN\n",
       "2003-01-06         NaN\n",
       "2003-01-07         NaN\n",
       "2003-01-08         NaN\n",
       "2003-01-09         NaN\n",
       "2003-01-10         NaN\n",
       "2003-01-13         NaN\n",
       "2003-01-14         NaN\n",
       "2003-01-15         NaN\n",
       "2003-01-16         NaN\n",
       "2003-01-17         NaN\n",
       "2003-01-20         NaN\n",
       "2003-01-21         NaN\n",
       "2003-01-22         NaN\n",
       "2003-01-23         NaN\n",
       "2003-01-24         NaN\n",
       "2003-01-27         NaN\n",
       "2003-01-28         NaN\n",
       "2003-01-29         NaN\n",
       "2003-01-30         NaN\n",
       "2003-01-31         NaN\n",
       "2003-02-03         NaN\n",
       "2003-02-04         NaN\n",
       "2003-02-05         NaN\n",
       "2003-02-06         NaN\n",
       "2003-02-07         NaN\n",
       "2003-02-10         NaN\n",
       "2003-02-11         NaN\n",
       "2003-02-12         NaN\n",
       "                ...   \n",
       "2011-09-05    0.752357\n",
       "2011-09-06    0.745761\n",
       "2011-09-07    0.741550\n",
       "2011-09-08    0.738944\n",
       "2011-09-09    0.746317\n",
       "2011-09-12    0.743924\n",
       "2011-09-13    0.745615\n",
       "2011-09-14    0.748272\n",
       "2011-09-15    0.747067\n",
       "2011-09-16    0.748199\n",
       "2011-09-19    0.731196\n",
       "2011-09-20    0.731751\n",
       "2011-09-21    0.728798\n",
       "2011-09-22    0.735271\n",
       "2011-09-23    0.740145\n",
       "2011-09-26    0.731302\n",
       "2011-09-27    0.725213\n",
       "2011-09-28    0.725128\n",
       "2011-09-29    0.715894\n",
       "2011-09-30    0.721275\n",
       "2011-10-03    0.725977\n",
       "2011-10-04    0.715843\n",
       "2011-10-05    0.718517\n",
       "2011-10-06    0.714363\n",
       "2011-10-07    0.718846\n",
       "2011-10-10    0.736464\n",
       "2011-10-11    0.729906\n",
       "2011-10-12    0.728404\n",
       "2011-10-13    0.727165\n",
       "2011-10-14    0.729858\n",
       "Length: 2292, dtype: float64"
      ]
     },
     "execution_count": 299,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c8e3048>"
      ]
     },
     "execution_count": 300,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corr.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 301,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c991dd8>"
      ]
     },
     "execution_count": 301,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.rolling(125,min_periods=100).corr(spx_rets).plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 302,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.stats import percentileofscore"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 303,
   "metadata": {},
   "outputs": [],
   "source": [
    " score_at_2percent = lambda x: percentileofscore(x, 0.02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 304,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = returns.AAPL.rolling(250).apply(score_at_2percent)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 305,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1e16c991dd8>"
      ]
     },
     "execution_count": 305,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
